System and method of computer operating mode control for power consumption reduction

ABSTRACT

An activity sensing power reduction and conservation apparatus, system, and method for a computer system. The computer system has resources including a processor, a memory, and an input/output device, and an operating system for controlling the resources. At least one of the resources can be placed into in any one of three operating modes including a first mode having a first power consumption level, a second mode having a second power consumption level less than the first level, and a third mode having a third level less than the second level. The first mode may be characterized by maintaining clocking of the processor at a first clock frequency, the second mode by clocking the processor at a second clock frequency less than the first frequency or by not maintaining clocking of the processor, and the third mode by maintaining operation of the memory to preserve the integrity of any stored memory contents. During operation of the computer system in the first mode, activity is monitored to detect completion of idle threads executing on the system, and the processor clock is slowed or stopped to at least that one resource in response to the idle thread completion detection. During operation in the second mode where the processor clock is slowed or stopped, a slow or stop resource command is generated to slow or turn off clock signal to at least one of the resources in response to occurrence of a timeout condition indication received from a timer circuit.

CROSS REFERENCE RELATED U.S. PATENT APPLICATION

This application is a divisional of Ser. No. 08/767,821 Dec. 17, 1996U.S. Pat. No. 5,892,959 which is a continuation of Ser. No. 08/460,191Jun. 2, 1995 abandoned, which is a continuation of Ser. No. 08/285,169Aug. 3, 1994 abandoned which is a continuation of Ser. No. 08/017,975Feb. 12, 1993 U.S. Pat. No. 5,396,635 which is a continuation of Ser.No. 07/908,533 Jun. 29, 1992 abandoned which is a continuation of Ser.No. 07/532,314 Jun. 1, 1990 abandoned.

BACKGROUND OF THE INVENTION

A portion of the disclosure of this patent document contains materialwhich is subject to copyright protection. The copyright owner has noobjection to the facsimile reproduction by anyone of the patent documentor the patent disclosure, as it appears in the Patent and TrademarkOffice patent file or records, but otherwise reserves all copyrightrights whatsoever.

The present invention relates to computers and particularly to methodsand apparatus for power management in computers, particularly inbattery-powered computers.

The major parts of computers include a central processing unit (CPU),input/output (I/O) devices such as display screens, keyboards, modems,printers, disk drives and the like, and storage (memory).

The CPU communicates with the I/O devices, with the storage andotherwise operates with addresses defined within the computer addressrange. Typically, addresses for I/O devices are within an I/O addressrange. Addresses for execution of programs without I/O referencetypically are within a memory address range. Similarly, that portion ofmemory allocated for display is within a video memory address range.

Computers function to execute application programs such as wordprocessing, spreadsheet and data base management programs. Typically,the computer and the application programs are under the control of asoftware operating system that manages the different system parts andresources including some I/O devices. For example, during the executionof an application program when the CPU wishes to check to determine ifany key has been depressed on the keyboard, the CPU through a subroutinecall to the operating system requests the operating system throughexecution of a subroutine to perform a key-actuation detection task.Since the operating system performs many such tasks, the operatingsystem has a detailed knowledge of many activities within the computer.However, under some circumstances, application programs bypass theoperating system and directly address I/O devices. Typically, each I/Odevice is assigned an I/O address within an I/O address range. Forapplication programs which directly address I/O devices withoutoperating system calls, the operating system is not immediately aware ofI/O activity. With such complex operation in computers, the task ofpower conservation is difficult.

The need for power conservation is well known in battery-poweredcomputers and must be performed in a manner that does not interfere withthe operation of the computer or impede users from interacting with thecomputer during the execution of application programs.

Conservation of power has been utilized for some parts ofbattery-powered computers but has been ignored for other parts of suchcomputers. In general, power consumption is distributed inbattery-powered computers among the major parts of those computers. Onepart with significant power consumption is the central processing unit(CPU). Another part is the input/output (I/O) devices such as displayscreens, keyboards, modems, printers, disk drives and the like. Stillanother part with significant power consumption is storage (memory).

Prior art attempts at conserving power have employed screen blankingwhich reduces the power to the display screen when the screen has notbeen used for some period of time. Typically, a timeout circuit senseschanges in screen information and, if no change has occurred for apredetermined timeout period, the backlight to the screen is turned offfor power reduction. While screen blanking is effective in reducingpower for the display screen, no reduction results in power to thedriver circuitry for the display, to the CPU, or to other parts of thecomputer. Furthermore, when the screen is blanked, the computer cannotbe used until reset.

Other prior art attempts at conserving power consumption have focused ondisk drives because the power consumption of rotating magnetic disks ishigh. Disk drive manufacturers have employed various schemes forreducing the power consumption of the disk drive. While such powerconsumption schemes are effective for the disk drive, no reductionresults in power to the CPU or other parts of the computer. Computerswithout disk drives, such as small "notebook" computers, have no need,of course, for the conservation of power in a disk drive.

In order to extend the battery life of portable computers and to managepower in computers, there is a need for improved power managementmethods and apparatus in computers, particularly for power managementthat can be extended to many different parts and conditions of thecomputer.

SUMMARY OF THE INVENTION

The present invention is a method and apparatus for power management ina computer. The computer typically includes as hardware a centralprocessing unit (CPU), storage (memory) and I/O devices and includes assoftware an operating system adapted to control the computer duringapplication program execution.

The power management method and apparatus causes the computer system toenter the power conservation mode after sensing inactivity by a softwaremonitor or by a hardware monitor.

The software monitor monitors the activity of the operating system orother software in the system. The software monitor typically is asoftware module linked, for example, to the operating system at boottime for monitoring subroutine calls to the operating system.

The hardware monitor monitors the hardware to detect inactivity. Thehardware monitor typically is circuitry for detecting inactivityindependently from the software. For example, the hardware monitorsenses predetermined address ranges, such as an I/O address range and avideo memory address range, and monitors the activity of addresses bythe CPU to addresses within these ranges. If no data transfers occurwithin the specified address ranges for predetermined periods of time,then a power conservation mode is entered to conserve power in thecomputer system.

By using both a software monitor and a hardware monitor, the powermanagement unit determines exactly when to enter into power conservationmode without sacrificing system performance.

In the software monitor, inactivity is determined by detecting how many"active" or "idle" function calls an application makes within some timeperiod. In the IBM PC DOS environment, the activity status is checked,for example, no less frequently than every 50 milliseconds. There are256 IBM PC DOS function calls and, in principle, each is labeled as"idle" or "active" and each is assigned a corresponding positive ornegative number. A positive number is assigned to an "active" functioncall and a negative number to an "idle" function call.

The power management software monitor forms an activity measurement as arunning total of the function call numbers as the function calls aremade. Whenever a function call is made (either active or conservation),the power management software monitor algebraically adds the functioncall number to the accumulated value and determines whether the systemis to remain in the active mode or be switched to the conservation modeby comparing the magnitude of the accumulated value with a function callthreshold.

The function call threshold for determining activity is a variabledepending on the computer system speed. To prevent the system fromoscillating between the active and conservation mode due to minorchanges in system activity, hysterisis is provided by using active andconservation function call thresholds. The accumulated total for theactivity measurement is reset after it reaches the active thresholdgoing in one direction or the conservation threshold going in theopposite direction as the case may be.

The active and conservation thresholds are typically unequal so that theentry and exit from conservation mode is biased. For example, in orderto have the system enter the conservation mode quickly and thereby toreduce power consumption, the active threshold is set with a numbergreater than the number for the conservation threshold.

In one embodiment, functions that require immediate attention areassigned numbers large relative to the active and idle thresholds sothat a single occurrence of the function call will force the accumulatedcount over the active threshold and thus force the system to be in theactive mode. The hysterisis effect can be bypassed by forcing the powermanagement unit into active mode without changing the activity count. Inthis case, the next idle function call will bring the system back toidle mode.

If the software monitor or the hardware monitor indicates inactivity,the power management unit enters the conservation mode. The conservationmode has multiple states which provide different levels of powerconservation.

A first state, called a DOZE state, is entered after sensing inactivityby the hardware monitor for a first period of time. A second state,called a SLEEP state, is entered after sensing inactivity by thehardware monitor for a second predetermined time where the secondpredetermined time is greater than the first predetermined time. A thirdstate, called a SUSPEND state, is entered after sensing inactivity bythe hardware monitor for a third period of time greater than the firstand second time periods.

Another state is OFF which turns off all power for the computer underpredetermined conditions.

During periods of inactivity, power consumption is reduced in differentways, for example, by reducing clock speeds or removing clocks, and/orby removing power, and/or by controlling the refresh frequency tomemory.

In accordance with the above summary, the present invention achieves theobjective of providing an improved power management method andapparatus.

The foregoing and other objects, features and advantages of theinvention will be apparent from the following detailed description inconjunction with the drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 depicts a block diagram of a computer with the power managementunit of the present invention.

FIG. 2 depicts a block diagram of the power management unit of the FIG.1 system.

FIG. 3 depicts a detailed block diagram of the hardware for the powermanagement unit of FIG. 2.

FIG. 4 depicts a state diagram depicting the multiple states associatedwith the power management unit of FIGS. 1, 2 and 3 as determined by thehardware monitor.

FIG. 5 depicts a representation of operation for various states as afunction of the activity measurement.

FIG. 6 depicts a state diagram depicting switching to conservation mode(DOZE or SLEEP state) operation under control of the software monitor.

FIG. 7 depicts a state diagram depicting the sequencing which forces tothe ON state during an activity window period under control of thesoftware monitor.

FIG. 8 depicts a representation of operation for a spreadsheetapplication program.

FIG. 9 depicts a representation of operation for a word-processingapplication program.

FIG. 10 depicts a representation of operation for a windowingapplication program.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

Computer System--FIG. 1

In FIG. 1, computer 3 is typically a small, battery-powered computersuch as a "notebook" computer. The computer 3 includes a CPU 4, a CPUbus 5, a plurality of I/O controllers 6-0, . . . , 6-n where "n" is aconstant equal, for example, to 7. Connected to the controllers 6-0through 6-n are plurality of peripheral devices 7-0, . . . , 7-n,respectively. The controllers and peripheral devices 6 and 7 typicallyinclude a keyboard, a display, a hard disk drive, a modem, a printer,and similar devices. Each of the controllers 6-0 through 6-n connects tothe conventional computer bus 5.

Also connected to the bus 5 is the memory, which in one particularembodiment is DRAM random access memory 11. The memory 11, when of thetype requiring refresh, is refreshed with *RAS and *CAS lines 29 undercontrol of the PC controller 13 which provides *PCRAS and *PCCAS signalson lines 30 to power management unit 15 including a hardware monitor 79and a software monitor 80. The I/O devices are separately poweredthrough switch unit 22 and switches 22-0, . . . , 22-n by the VCC powerfrom power supply 9 which receives power either from the battery 10 oran AC source 14. Power supply 9 is of a conventional type which suppliesa low battery signal LB, a low-low battery signal LLB, and an AC powersignal ACPWR to power management unit 15.

The computer 3 typically includes as software an operating systemadapted to control the computer system and to control operations duringapplication program execution. Computer 3 functions to executeapplication programs such as word processing, spreadsheet and data basemanagement programs. Computer 3, during the execution of applicationprograms, is under control of a software operating system. The operatingsystem manages the different system parts and resources including theI/O devices 6 and 7. For example, during the execution of an applicationprogram when the CPU wishes to check to determine if any key has beendepressed on a keyboard I/O device, the CPU 4 through a subroutine callto the operating system requests the operating system to execute asubroutine to perform a key-actuation detection task. Since theoperating system performs many similar calls to the operating system,these calls represent detailed information about many activities withinthe computer system.

In FIG. 1, the computer 3, through the CPU 4, issues control and addresssignals on the bus 5 which define the overall computer address range forcomputers including the sets of address ranges for all of the memory,I/O and other devices connected to the bus 5. Whenever any of theperipherals 7-0 to 7-n are to be accessed for data to be transferredover the bus 5, the address of the corresponding I/O controller 6-0 to6-n (either by unique address lines or unique address lines incombination with control lines) specifies the addressed one of the I/Ocontrollers 6 and corresponding peripheral 7.

Similarly, memory 11 has locations addressed by a set of addresses onbus 5 within a memory address range. Some of the addresses in the rangeof addresses for memory 11 are typically allocated and reserved only asa set of video memory addresses. Whenever the video memory region 8 ofmemory 11 is to be addressed, address appears on bus 5 within the set ofvideo memory addresses.

The computer system of FIG. 1 includes a power management unit 15 havinga software monitor 80 and a hardware monitor 79 for monitoring activityof the computer system. The power management unit 15 is connected to thebus 5 to sense activity, using hardware monitor 79, on the bus 5 and isconnected to the CPU 4 (executing the operating system and the softwaremonitor 80), the power supply 9, the memory 11 and PC controller 13 forcontrolling power management.

The power management unit 15 of FIG. 1 operates to cause the computersystem to enter the power conservation mode after sensing inactivity bythe hardware monitor 79 or by the software monitor 80 and to enter theactive mode after sensing activity or other conditions.

The hardware monitor 79 monitors the hardware to detect inactivity. Thehardware monitor 79 typically is circuitry for detecting inactivityindependently from the software and the software monitor 80. Forexample, the hardware monitor 79 senses predetermined address ranges,such as an I/O address range and a video memory address range, andmonitors the activity of addresses by the CPU to addresses within theseranges. If no data transfers occur within the specified address rangesfor predetermined periods of time, then a power control mode is enteredto conserve power in the computer system.

The software monitor 80 monitors the activity of the operating system orother software in the system. The software monitor 80 typically is asoftware module linked, for example, to the operating system at boottime for monitoring subroutine calls to the operating system.

By using a software monitor 80 and a hardware monitor 79, the powermanagement unit 15 decides exactly when to enter into power conservationmode and active mode without unnecessarily sacrificing systemperformance.

The power conservation mode includes a number of activity states. Afirst state, called a DOZE state, is entered after sensing inactivityfor a first period of time by the hardware monitor or when an idlethreshold is exceeded as determined by the software monitor. A secondstate, called a SLEEP state, is entered after sensing inactivity by thehardware monitor for a second predetermined time where the secondpredetermined time is greater than the first predetermined time or whenthe activity measurement sensed by the software monitor exceeds the idlethreshold. A third state, called a SUSPEND state, is entered aftersensing inactivity for a third period of time greater than the first andsecond time periods. Another state is OFF which turns off all power forthe computer under predetermined conditions.

After having entered one or more of the activity states of theconservation mode, the power management unit switches back to the activemode when activity is sensed by the monitors.

Power Management Unit--FIG. 2

In FIG. 2, a block diagram of the power management unit 15 of FIG. 1 isshown. The power management unit includes a hardware monitor 79(including an activity monitor 16 and a timer unit 24), a softwaremonitor 80, a state control unit 23, a power control unit 17, a clockcontrol unit 18, and a refresh control unit 20. The hardware monitor 79(using activity monitor 16) analyzes the address activity on the systembus 5 to provide activity information used to control power management.The timer unit 24 times the activity information sensed by the monitor16. The state control unit 23 controls the changes among different powerconsumption states to achieve power management.

The power control unit 17 controls the switches 22-0, . . . , 22-n ofFIG. 1 as a function-of the activity sensed by activity monitor 16 andthe state determined by state control unit 23.

The clock control unit 18 controls the distribution of and/or thefrequency of the CPU and other clocks as a function of the activitysensed by the activity monitor 16 and the state determined by statecontrol unit 23.

The refresh control unit 20 controls the refresh of the RAM memory 11 ofFIG. 1 at a rate which is determined by the activity sensed by theactivity monitor 16 and state control unit 23.

The power management unit (PMU) 15 is provided to manage power andreduce, over time, the overall power consumption of computer 3. Thismanagement is accomplished using an activity monitor 16 to detectperiods of system inactivity. During periods of inactivity, powerconsumption is reduced by reducing clock speeds or removing clocksthrough clock control unit 18, and/or by removing power through powercontrol unit 17, and/or by controlling the refresh frequency throughrefresh control unit 20. Standard and slow refresh DRAM support isprovided by refresh control unit 20. Inputs are provided to the powermanagement unit 15 which will allow power on or off commands fromexternal sources such as a pushbutton, modem ring indicator, orread-time-clock (RTC) time of day alarm.

Hardware Monitor Generally--FIG. 3

Referring to FIG. 3, the power management unit (PMU) 15 includes thehardware monitor 79 (activity monitor 16 and timer unit 24) which isdesigned to operate with minimal system requirements and withoutsoftware support. Power management occurs in response to the hardwaremonitor independently of any operating system (DOS) or applicationprogram support.

In FIG. 3, the PMU 15 has its own power-on reset signal (*RESET) whichis produced by a VCC power detector 71, separate from any other resetsignal of computer 3, and upon initial power-on, the registers of thepower management unit 15 are initialized to preestablished defaultvalues to provide basic functionality without need of any software.

While the hardware monitor 79 and the power management unit 15 areprovided FIG. 3 as a hardware embodiment, a software embodiment of thehardware monitor 79 is described in the program listing of TABLE 1.Using the program listing of TABLE 1 executing in the CPU 4, powermanagement, using a software embodiment of a hardware monitor, occursunder program control.

In accordance with the operation of the hardware monitor 79, apredetermined set of address ranges on bus 5 is monitored by powermanagement unit 15 as part of the power management operation. Forexample, the predetermined set of address ranges monitored for powermanagement typically includes all of the I/O address range, that is, theaddresses of the I/O controllers 6-0 through 6-n and the video memoryaddress range for the video memory locations 8 within the memory 11. Ofcourse, other address ranges can be added to or used as thepredetermined set for power management. The set of address rangesincluding the video memory and the I/O address ranges has been found toprovide excellent information for controlling power management.

The hardware monitor 79 senses the activity of addresses on the bus 5.Whenever addresses within the predetermined set of addresses are notpresent on the bus 5 for predetermined time periods, the powermanagement unit 15 responsively switches power consumption states andcontrols the consumption of power by different parts of the computer 3.

The power management unit 15 has four main operating states, namely, ON,DOZE, SLEEP, and SUSPEND, and a fifth state which is OFF. The five powermanagement states, under control of the hardware monitor 79, are shownby the state diagram of FIG. 4. The activity monitor 16, external inputs(EXT, RESET), and the timeouts of timer unit 24 generally control thetransitions between states in the state control unit 23 as shown in thestate diagram of FIG. 4. The CPU 4 of FIG. 1 may also command the PMU 15to enter any state. The commands from the CPU 4 typically derive fromexecution of the software monitor 80, but may derive from other CPU 4commands.

In FIG. 3, each of the four active states (not OFF) has an associatedPWR register which indicates in one embodiment which of eight powercontrol outputs VP[0 . . . 7] on lines 33 will be active during thestate. More generally, any number, (n+1), outputs VP[0 . . . n] can beemployed. The PWR registers in power control unit 17 are PWRON register57, PWRDOZE register 58, PWRSLEEP register 59 and PWRSUSPEND register 60as shown in FIG. 3. A power control multiplexer 76 selects the eightoutputs from one of the registers 57 through 60 corresponding to thecurrent state on STATE lines 34 from unit 23, and these eight outputsdrive the VP[0 . . . 7] power control outputs from EXOR unit 35. Also,the CPU 4 of FIG. 1 can write, under program control, to any of the PWRregisters 57 through 60 to control which of the I/O devices 6 and 7 arepowered at any time.

To turn an I/O device on, the corresponding bits in the PWR registers 57through 60 for the state(s) in which they are to be on is typicallyhigh. The POLARITY register 61 specifies the actual polarity of eachoutput VP[0 . . . 7] required to turn the associated one of the switches22-0, . . . , 22-n on and thereby supply power to the I/O devices 6 and7. The default value of the POLARITY register is 03h, which implies alogic low to turn on VP[2 . . . 7], which will typically control logicswitches 22 with low-true output enables (for example, switches 22typically include a PNP transistor in the VCC line from power supply 9)and high to turn on the LCD, VP[0], and EL backlight, VP[1], power. Thevalue of the VP[0 . . . 7] bits just prior to the polarity control byEXOR 35 may be read back through the OUTPUT register 62 to CPU 4 overbus 5.

The system clock oscillator signal CLKI is connected to the CPU ClockControl block 49 to produce the CLKOUT. From there CLKOUT, as controlledby PMU 15 and control block 49, drives CPU 4. The CLKOUT clock can bestopped for static CPU's, or reduced automatically by a divisorspecified in the CLOCK field of control register 53 during DOZE andSLEEP states. CLKI is passed through unchanged to CLKOUT in SUSPENDstate.

Detailed implementations of the various monitor, control and logicblocks of FIG. 3 will be clear from the following detailed description.Additionally, a software embodiment of the hardware monitor 79 includinglogic and control functions equivalent to those in the hardwareembodiment appears as the Program Listing of TABLE 1.

Software Monitor Generally

The software monitor 80 of FIG. 2 includes a power management softwaremodule linked into the operating system, for example, during boot uptime. One embodiment of the module appears as the program listing ofTABLE 2.

The software monitor 80 monitors all the function calls to the operatingsystem. Every time an idle function call is made, the activitymeasurement, AC(t), is incremented and then checked against thresholds.The incrementing is algebraic by the amount of D_(a), a positive DOScall number, or D_(i), a negative DOS call number.

If the activity measurement, AC(t), is below the idle threshold, T_(H),and the system is in the active mode, no action will be taken. However,if the activity measurement, AC(t), is above the idle threshold, T_(H),the power management software will check the current system status andif in the active mode, will switch to the conservation mode.

The activity measurement, AC(t), is given by the following Eq. (1):##EQU1## where,

D_(a) (t)=Active DOS call numbers as a function of time

D_(i) (t)=Idle DOS call numbers as a function of time

AC(t)=Accumulated Activity Count of DOS call numbers as a function oftime, that is, activity measurement

While all of the interrupts of the operating system may be assigned aD_(a) or D_(i) value the following, for example in the following CHART1.

    ______________________________________                                        CHART 1                                                                       INTERRUPT        CALL NUMBER TYPE                                             ______________________________________                                        I16 (keyboard poll)                                                                            +12         Di                                               I10 (video active)                                                                             -25         Da                                               I8 (timer)       -25         Da                                               I14 (communications)                                                                           -400        Da                                               ______________________________________                                    

Using the values in CHART 1, each time an interrupt 16 (I16) occurs, thesoftware monitor increments AC(t) by +12 and each time I10 or I8 occursthe software monitor increments AC(t) by -25. The value of AC(t) isshown for one example of operation in FIG. 5.

Referring to FIG. 5, the value of AC(t) as a function of t is shown. Inthe example of FIG. 5, the first eight values of t find keyboard pollingoccurring by the I16 interrupt so that +12 is added to AC(t) for each ofthe first eight values of t. In FIG. 5, at t=8, the timer interrupt I8occurs and subtracts -25 from the AC(t) value. Thereafter the keyboardpolling continues until the value of AC(t) reaches 128, the value ofT_(H) in the example of FIG. 5. At t=12 in FIG. 5, AC(t) is reset, forexample, to 0 when the computer system enters the conservation (idle)mode. At about t=20 in FIG. 5, which may include a long time durationgenerally indicated by the broken line at about t=15, video interruptI10 becomes active and starts to add -25 to the AC(t) value until atabout time t=35 the value of AC(t) reaches the -256 value of thethreshold T_(L).

When the value of AC(t) is above T_(H), then the software monitor isoperative to switch the computer system into the conservation mode.Whenever AC(t) is in below the threshold T_(L), the software monitor isoperative to switch the computer system back to the active mode.

The example of FIG. 5 is only for purposes of representing the manner inwhich AC(t) is incremented as a function of the positive and negativeinterrupt call numbers. Of course, other counting methods may beemployed. In the program of TABLE 2, after the T_(H) value of +128 isreached, the counter is reset to +256 and each value of Da decrementsthe count until the threshold TL is reached at 0.

The operation which occurs when the value of AC(t) exceeds the thresholdT_(H), is explained with respect to the flowchart of FIG. 6.

In FIG. 6, the value of D (either Da or Di), the interrupt number value,is added as indicated in Eq. (1) to form the accumulation value of theactivity measurement, AC(t). This accumulation is indicated by the ovalmarked D in FIG. 6.

Next, the value of AC(t) is compared with the threshold T_(H). If thevalue of the summation in Eq. (1) is not greater than the threshold,T_(H), then the N no choice is made the loop repeats so that the nextvalue of D is added to the AC(t) activity measurement. For example, inFIG. 5, this activity continues until approximately t=12 in FIG. 5.

In FIG. 5, at about t=12, the activity measurement AC(t) equals orexceeds the threshold T_(H) and hence the Y output of the comparisonconnects to the SLEEP state detector. If already in the state, then theY output will force the computer system to remain in the SLEEP state. Ifnot in the SLEEP state, then the software monitor will force thecomputer system into the DOZE state.

Note that the FIG. 6 operation will force the computer system into theDOZE or SLEEP state as long as the activity measurement AC(t) exceedsthe threshold T_(H). When the threshold T_(H) has been exceeded, AC(t)is reset and remains reset until another activity event, Da or Di,occurs. In FIG. 5, for example, this occurs at about t=20 when AC(t)begins to count toward T_(L).

In addition to the comparison of the activity measurement AC(t) againstthe upper threshold T_(H), the software monitor 80 also compares thevalue of the activity measurement against the lower threshold T_(L).This comparison is represented by the flowchart of FIG. 7.

In FIG. 7, the oval represents the incrementing of the activitymeasurement AC(t) in accordance with Eq. (1). After each incrementing ofthe activity measurement, the value of AC(t) is compared to determine ifit is less than or equal to T_(L). If not, then the N output of thecomparison continues the incrementing of the activity measurement foreach new value determined in accordance with Eq. (1).

If the activity measurement AC(t) is less than or equal to T_(L), thenthe Y output of the comparison connects the operation to the activitywindow comparison.

If AC(t)≦T_(L) and AW(t)≦T_(aw), then the FIG. 7 operation switches tothe ON state.

If AC(t)≧T_(H), then test sleep state.

where,

T_(H) >K₁

T_(L) <K₂

T_(H) =Idle Threshold

T_(L) =Activity Threshold

K₁ =128

K₂ =-256

Combined Hardware Monitor and Software Monitor Operation

If the system is in ON state and AC(t) is greater than or equal toT_(H), the power management software monitor will bring the system intoDOZE state. If the system is already in DOZE or SLEEP state, no furtheraction will be needed. Similarly, the activity count, AC(t), will bedecremented every time an active function call, Da, is made. Theactivity count is then used to compare with the active threshold. If thecount is higher than the active threshold, T_(H), then the powermanagement software monitor 80 will force the system into the powerconservation mode (DOZE or SLEEP) per the FIG. 6 operation regardless ofthe status of the hardware monitor 79. If the activity count is equal toor less than the active threshold, T_(L), then the system will beprogrammed into the ON state.

The ON state can also be entered if the hardware monitor 79 detects apredetermined set of address ranges on bus 5. For example, thepredetermined set of address ranges monitored for power managementtypically includes all of the I/O address range, that is, the addressesof the I/O controllers 6-0 through 6-n, and the video memory addressrange for the video memory locations 8 with the memory 11. Of course,other address ranges can be added to or used as the predetermined setfor power management. The set of address ranges including the videomemory and the I/O address range has been found to provide excellentinformation for controlling power management.

After entering the ON state, the power management unit will continue tobe in the ON state until any idle function call detects the activitycount has reached or gone beyond the idle threshold, T_(H).

There are application programs such as Microsoft's Windows described inconnection with FIG. 10 that do not use the DOS idle function calls andtherefore the system would never go into the DOZE state throughoperation of the software monitor 80. Therefore, a watch dog timer isbuilt into the power management software monitor to monitor the absenceof idle function calls as indicated in connection with FIG. 7. If a timeperiod greater than T_(aw) as shown in the flow chart in FIG. 7 has beenexceeded without any idle function call being made, then it is assumedthat the application program bypasses DOS and goes directly to thehardware.

During the T_(aw) time period (see FIG. 7) the power management unitwill be forced into the ON state until detection of activity forpredetermined period of time, T_(aw). This period, T_(aw) is normallymore than a minute in order not to affect the system performance. Thereis no power saving during the time out period, T_(aw), even if the CPUis actually idling. After the T_(aw) time period, the hardware monitor79 will take over completely.

In most cases, application programs go through DOS to perform I/Ooperations. The power management software monitor 80 keeps track of allthe operating system function calls. If the accumulative count of allactive and idle function calls is greater than the upper threshold,T_(H), then the system is assumed to be inactive. The power managementsoftware monitor will program the power management unit to DOZE stateonly if the system is still in ON state. The computer 3 will enter DOZEstate without waiting for the ON state timer to expire and thereforemaximizes the power saving of the system. If computer 3 is already inDOZE or SLEEP, no action will be needed from the power managementsoftware monitor until the system becomes active again.

In the software monitor 80, inactivity is determined by detecting howmany active or idle function calls an application makes within some timeperiod. In the IBM PC DOS environment, the activity status is checked noless frequently than every 50 milliseconds. There are 256 IBM PC DOSfunction calls and each is labeled as idle or active with acorresponding positive or negative number. A positive number is assignedto an active function call and a negative number to an idle functioncall. The power management software module keeps a running total of theaccumulated value of the function call numbers as the function calls aremade. Whenever a function call is made, (either active or idle), thepower management software module algebraically adds the number to theaccumulated value and decides whether the system is active or not bycomparing the magnitude of the accumulated value with a function callthreshold. The function call threshold for determining activity is avariable depending on the computer system speed.

To prevent the system from oscillating between the active and idle statedue to minor changes in system activity, hysterisis is provided by usingactive, T_(L), and idle, T_(H), function call thresholds. Theaccumulated total is clamped at T_(H) after it reaches the activethresholds T_(H) or T_(L) as the case may be. The active and idlethresholds are typically unequal (128 and -256) so that the entry andexit from conservation (idle) mode is biased. For example, in order tohave the system enter the idle mode quickly and thereby to reduce powerconsumption, the active threshold is set with a threshold number (128)greater than the idle threshold number (-256). Also, functions thatrequire immediate attention are assigned numbers large relative to theactive and idle thresholds so that a single occurrence of the functioncall (for example, I14=-400) will force the accumulated count over theactive threshold (T_(L) =-256) and thus force the system to be in theactive mode. The hysterisis effect can be bypassed by forcing the powermanagement unit into active mode without changing the activity count. Inthis case, the next idle function call will bring the system back toidle mode.

If the software monitor 80 or the hardware monitor 79 indicatesinactivity, the power management unit enters the conservation mode whichhas multiple states with different levels of power conservation.

The hardware monitor 79 works in conjunction with the software monitor80 linked to the operating system during boot up time. The state controlunit 23 is controlled by the timer unit 24 and power management softwaremodule 100. The power management software will override the hardwaretimer unit 24 whenever inactivity is detected in the operating systemlevel. Since this can be done in a much finer resolution than thehardware monitor 79, the combined software and hardware monitor maximizepower saving without any degradation in system performance.

Power Management Unit Detail--FIG. 3

Line List

In FIG. 3, the following lines and functions are defined for theconnections output (O) from and input (I) to the PMU 15 of FIGS. 1 and2.

    ______________________________________                                        Name       Type     Function                                                  ______________________________________                                        SA[0. .9]      I        System Address on bus 5                               SD[0. .7]      I/O      System Data on bus 5                                  VP0            O        LCD power control                                     VP1            O        EL backlight power control                            VP[2. . 7]     O        Peripheral power control                              *RAS           O        *RAS for DRAM                                         *CAS           O        *CAS for DRAM                                         *PCRAS   I     *RAS     for DRAM                                              *PCCAS   I     *CAS     for DRAM                                              *VCS           I        Video RAM chip select                                 *IOR           I        I/O Read                                              *IOW           I        I/O Write                                             *S1            I        Status, low indicates read or mem                                             read operation                                        AEN            I        DMA enable                                            INMI           I        NMI input from user system                            NMI            O        NMI output to CPU                                     INTR           I        Int request output of computer                        DRQ[0..3]      I        DMA requests which could occur in                                             DOZE  or SLEEP                                        *DACK0   I     Indicates refresh DMA cycle                                    EXT            I        External command input (button)                       RI       I     Ring indicator from modem                                      RTC            I  Alarm output from RTC                                       CLKI           I  CPU clock input                                             CLKOUT   O     Clock out to CPU                                               LB       I     Low battery detect, first warning                              LLB            I  Low battery detect, second warning                          ACPWR    I     AC power good input                                            *RESET   I     External RC required for reset                                 *REFRSEL       O  Low when PMU controls DRAM refresh                          OSC            I  Xtal osc output                                             CLK1IN   I     Clock 1 in for switched clock 1 out                            CLK1OUT  O     Switched clock 1 out                                           CLK2IN   I     Clock 2 in for switched clock 2 out                            CLK2OUT  O     Switched clock 2 out                                           LBPOL    I     Low battery polarity select                                    STATIC.sub.-- CPU I                                                                      Connect to Vcc if CPU is static                                    VCC             Power                                                         VSS             Ground                                                        ______________________________________                                    

Registers

In FIG. 3, the PMU 15 includes a number of registers accessed for reador write by CPU 4 over bus 5 via an index register addressing scheme.When not accessed by CPU 4, for example, after a power on detection bydetector 71, the registers are all initialized to a default state. Whenaccessed by CPU 4, an index value is first written to the index register50 from bus 5 and the index value is decoded by decoder 70 to select oneof the registers of PMU 15 for access to bus 5 to receive or sendinformation from or to CPU 4. The index register 50, after an indexwrite, is changed to point to another register to be accessed. Whenreset, the index register is not active to enable any PMU 15 register.This is a safety feature to help prevent applications executing on theCPU 4 from inadvertently accessing PMU 15 registers. All registers maybe read and written over bus 5.

The PMU 15 data registers are:

    ______________________________________                                        Data Register (Ref. No.-FIG. 3)                                                                       Index Decode                                          ______________________________________                                        STATUS       51                   00H                                         SUPPLY       52                   02H                                         CONTROL      53                   04H                                         ACTMASK      54                   06H                                         NMIMASK      55                   08H                                         OSC                         56          0AH                                   PWRON        57                   OCH                                         PWRDOZE      58                   0EH                                         PWRSLEEP                    59          10H                                   PWRSUSPEND           60           12H                                         POLARITY                    61          14H                                   OUTPUT       62                   16H                                         DOZE                        63          18H                                   SLEEP        64                   1AH                                         SUSPEND      65                   1CH                                         LCD                         66          1EH                                   EL           67                   20H                                         ______________________________________                                        Status Register                                                               Bit       Name        Function                                                ______________________________________                                        D7        RESUME      Resuming from SUSPEND                                                         (warm start)                                            D6        WU1         Wakeup code MSB                                         D5        WU0         Wakeup code LSB                                         D4        NMI2        \                                             D3        NMI1        > NMI cause code                                        D2        NMI0        /                                                       D1        STATE1      State MSB                                               D0        STATE0      State LSB                                               ______________________________________                                    

In register 51, only D0 and D1 are affected by a write. The CPU 4 canwrite the state code to this register to put the PMU in another state.Writing OFFh puts it in the OFF state. The NMI cause, state and wakeupcodes are decoded as follows:

    ______________________________________                                        Code                                  Code                                    Wakeup NMI Cause     Code    State    Cause                                   ______________________________________                                        000    None, or INMI 00      On       00                                      001    EXT input     01      DOZE     01 EXT                                  input                                                                         010    LB            10      SLEEP    10 RTC                                  input                                                                         011    LLB timeout   11      SUSPEND  11 R I                                  input                                                                         100    SLEEP timeout                                                          101    SUSPEND timeout                                                        ______________________________________                                         *RESET sets STATE[0 . . 1] and clears all other bits.                    

Supply Register

This register 52 is read only. D[0 . . . 2, 5] are driven directly bythe input lines. Bit D3 is set when system activity is detected and iscleared when this register is read.

    ______________________________________                                        Bit    Name         Function                                                  ______________________________________                                        D5     STATIC.sub.-- CPU                                                                          1 = Static CPU (clock stops in                                                DOZE)                                                     D4     DRAMRDY      1 = CPU controls DRAM (same as                                                *REFRSEL)                                                 D3     ACTIVITY     System activity present                                   D2     LLB          Low battery 2 (second warning)                            D1     LB           Low battery 1 (first warning)                             D0     ACPWR        AC power input in range                                   ______________________________________                                        Control Register                                                              Bit            Name     Default   Function                                    ______________________________________                                        D7             0                                                              D6     RING2   0        \                                           D5     RING1   0        > Number of RI pulses reguired                                                for turnon                                            D4     RING0   1        / default = 1                                         D3     STATIC.sub.-- CPU 0                                                                        For static CPU's                                          D2     SLOW    0        Clock runs slow in ON                                 D1     CCLK1   1        CPU Clock divisor, DOZE and SLEEP                     D0     CCLK0   0        / default divisor = 4                                 ______________________________________                                    

In register 53, the RING[0 . . . 2] bits are used to set the number ofRI pulses required for turnon. The default value is 1 so that only onepulse is required for turnon. If set to 0, RI is disabled. State logic23 has conventional logic for detecting and counting RI pulses from amodem, one of the I/O peripherals 7-0 to 7-n. D3 is only used for staticCPU's. SLOW indicates reduced clock speed operation in On. The CCLK[0 .. . 1] bits select the clock divisor for CLKOUT in SLEEP and DOZEstates, and in ON if SLOW is set, according to the table.

    ______________________________________                                               CCLK[0 . . 1]  Divisor                                                 ______________________________________                                               0              1                                                              1              2                                                              2              4                                                              3              8                                                       ______________________________________                                        ACTMASK Register                                                              Bit  Name        Default  Function                                            ______________________________________                                        D7               0                                                            D6   MSK.sub.-- VIDM                                                                           0        Mask access to video memory                         D5   MSK.sub.-- DMA                                                                            0        Mask all DMA activity                               D4   MSK.sub.-- P63                                                                            1        Mask access to port 63h                             D3   MSK.sub.-- PIC2                                                                           0        Mask access to port A0h, Alh                        D2   MSK.sub.-- RTC                                                                            1        Mask access to port 70h, 71h                        D1   MSK.sub.-- KBD                                                                            0        Mask keyboard (port 60H,64H)                        D0   MSK.sub.-- IO                                                                             0        Mask access to all ports not                                                  maskable by D[2 . . 5]                              ______________________________________                                    

The activity monitor ACTIVITY output is the logical OR of all unmaskedactivity sources. This register 54 affects only the ACTIVITY output.Refresh DMA cycles (*DACK0 low), interrupts, or accesses to the PMU 15,never affect the activity monitor 16.

NMIMASK Register

This register 55 masks the various NMI sources. In the default stateonly the INMI input can generate NMI.

    ______________________________________                                        Bit                                                                           Default  Name         Function                                                ______________________________________                                        D6       OS2          Mask INMI input                                                                              0                                        D5       MSK.sub.-- SUSPEND                                                                         Mask SUSPEND timeout                                                                         1                                        D4       MSK.sub.-- SLEEP                                                                           Mask SLEEP timeout                                                                           1                                        D3       MSK.sub.-- LLB                                                                             Mask LLB input 1                                        D2       MSK.sub.-- LB                                                                              Mask LB input  1                                        D1       MSK.sub.-- EXT                                                                             Mask EXT input 1                                        ______________________________________                                        OSC Register                                                                  Bit    Name       Default    Function                                         ______________________________________                                        D7     OSCDIV3    1          \                                      D6     OSCDIV2    1          OSC input divisor -1                             D5     OSCDIV1    0          default code = 1101                                                           (divisor = 14)                                   D4     OSCDIV0    1          /                                                D3                                                                            D2     SLWREF     0          Slow refresh DRAM                                D1     RASWIDTH1  0          *RAS pulse width MSB                             D0     RASWIDTH0  0          *RAS pulse width LSB                             ______________________________________                                    

Referring to register 56, OSCDIV[0 . . . 3] plus one is the OSCfrequency in MHz, except for OSCDIV[0 . . . 3]=13, the default,indicates 14.318 MHz. SLWREF is set when slow refresh DRAM is used.RASWIDTH[0 . . . 1] indicates the width of the *RAS pulse in units ofOSC periods. The default value is 0 which disables refresh in SUSPENDstate, and no RAS/CAS is generated. Values of 1 to 3 indicate 1 to 3 OSCperiods.

PWR Registers

The bits D[0 . . . 7] in these registers 57 through 60 corresponddirectly with the power control outputs VP[0 . . . 7]. In a particularstate, the corresponding PWR register outputs control the VP lines 23.The exception is VP0 and VP1 which are LCD and EL power, respectively.These outputs are AND'ed in AND gates 41 and 42 with the LCD and ELtimer outputs prior to driving the lines 33. All bits are then exclusiveNOR'ed in gates 35 with the POLARITY register 61, and the result drivesthe lines 33. The default values for these registers are as follows,where 1 indicates that the controlled device is on:

    ______________________________________                                        PWRON                  FFh                                                    PWRDOZE                FFh                                                    PWRSLEEP                 0Fh                                                  PWRSUSPEND             00h                                                    ______________________________________                                    

POLARITY Register

This register 61 controls the polarity of the VP outputs. If a logic lowis required on a VP line to turn the external device on, thecorresponding bit in the POLARITY register 61 must be low. If a high isrequired, set the bit high.

Timer Registers

The nonzero value loaded into one of the timer registers 63 through 68is the actual timeout minus one. A zero disables the timeout. Thereforea 4 bit timer can be set for a timeout from 1 to 15 time units. Readinga timer register returns the value that was last written to it, not theactual time remaining. The default values are tabulated below:

    ______________________________________                                        Timer          Range       Default                                            ______________________________________                                        DOZE           1-15 sec    5 sec                                              SLEEP          1-15 min    2 min                                              SUSPEND        5-75 min    0 (disabled)                                       LCD            1-15 min    TBD                                                EL             1-15 min    TBD                                                ______________________________________                                    

OUTPUT Register

The OUTPUT register 62 is a read only register. For each VP[0 . . . 7]output that is on, the corresponding bit in the OUTPUT register will beset.

The control and logic functions for the activity monitor 16, the statelogic 23, the NMI logic 21, and other components of FIG. 3 areconventional logic circuits for implementing the logic and controlfunctions hereinafter described or alternatively are the software logicof TABLE 1.

ON State

Referring to FIG. 4, the ON state is entered from the SUSPEND or OFFstate when the *RESET input is low, and also when one of EXT, RTC or RIgoes high if ACPWR is true or LB is false. It is entered from DOZE orSLEEP when the activity monitor 16 detects activity with addresses inthe predetermined address set. In the ON state encoded on lines 34, allpower control outputs VP[0 . . . n] will be controlled by the PWRONregister 57. Upon entering the ON state, the DOZE timeout timer 63 willbe retriggered. The LCD and EL timeouts in timers 66 and 67 will beretriggered when entering the ON state from SUSPEND or OFF. Theretrigger lines from STATE logic 23 to the timers are not shown in FIG.3 for clarity.

In FIG. 3, the STATE logic 23 recieves the CPU data bus D(0 . . . 7)from bus 5 for receiving state commands issued by the software monitor80 of TABLE 2. The STATE logic also receives the address detection line76 from activity monitor 16 which enables the STATE logic 23 to receivethe state commands from the software monitor when addressed over the bus5.

If the SLOW bit in the control register 53 is false, the CLKOUT rate online 28 will be full speed. If the SLOW bit is true, CLKOUT will be asspecified by the CCLK[0,1] bits in register 53. This clock controlallows the user to save power, for example, when runningnon-computationally intensive applications such as word processing.

DOZE State

The DOZE state is entered from the ON state when the activity monitor 16has not detected activity and therefore has not provided the ACTIVITYsignal within the time, T1, specified by the DOZE timer 63. In the DOZEstate encoded on lines 34, the power control outputs VP[0 . . . 7] fromunit 17 are controlled by the PWRDOZE register 58. If a non-static CPU 4is used, the clock on line 28 will be slowed as specified by CCLK[0,1]in register 53.

If a static CPU 4 is used, CLKOUT on line 28 will stop in the low stateimmediately following a non-DMA memory read instruction, as indicated by*S1 going high while *AEN is low, so that no chip select will be low. IfINTR goes high, CLKOUT will be enabled until after EOI is written to theinterrupt controller with INTR false. If INMI goes high, CLKOUT will beenabled. If an internally generated NMI occurs, CLKOUT will be enableduntil the NMIMASK register 55 is read. If any DRQ goes high, CLKOUT willbe enabled until after the next memory read instruction with AEN and allDRQ inputs false. The enable request functions for INTR, INMI, internalNMI and DMA are separate and CLKOUT is enabled when any event requestsit, so that an interrupt handler in CPU 4 will run to completion even ifit is interrupted by a DMA request. These enable request functions areindependent of the activity monitor and the ACTMASK register 54.Enabling CLKOUT does not cause the PMU 15 to leave DOZE, unless theactivity monitor 16 is subsequently triggered. If this trigger occurs,the PMU 15 will enter the ON state and the enable request logic will becleared.

SLEEP State

The SLEEP state is entered when the PMU 15 has been in the DOZE statefor the time, T2, specified by the SLEEP timer 64 and no ACTIVITY signalhas occurred. In the SLEEP state, the CLKOUT operation is the same as inDOZE. The power control outputs are controlled by the PWRSLEEP register59.

Alternatively, the PMU can be programmed to generate NMI and remain inDOZE state instead of automatically entering SLEEP.

SUSPEND State

The SUSPEND state is entered when the PMU 15 has been in the SLEEP statefor the time, T3, specified by the SUSPEND timer 65 or when a powercheck detects low battery signals, LB or LLB. The SUSPEND state isentered after these conditions only when the CPU 4 writes the code forSUSPEND to the STATUS register 40 and this operation requires softwaresupport because in SUSPEND the CPU operation is affected. In SUSPENDoperation, CLKOUT is the same as CLKI. The power control outputs arecontrolled by the PWRSUSPEND register 60. In SUSPEND, the CPU 4 and thedevice (for example, a switch) which generates the system reset signalmust be powered off. Only activity on the EXT, RI or RTC inputs cancause an exit from SUSPEND, and the new state after exit will be ON.When the reset circuit power is restored, it will reset the CPU 4, whichwill then execute a warm startup routine in a conventional manner. DRAMrefresh may be enabled in SUSPEND. If DRAM refresh is not enabled, thePMU 15 does not need OSC from unit 43 in SUSPEND, and gates it offinternally to minimize OSC power consumption. The OSC output will staylow. The bus interface is inhibited, and the data bus 5 is tristated.

OFF State

The OFF state is entered when the CPU 4 writes the code of OFF (OFFh) tothe STATUS register 51. It is also entered 5 seconds after the EXT inputgoes high if the NMI is not serviced.

The OFF state is meaningful only when the PMU 15 is powered from abattery while the rest of the computer 3 is turned off. This type ofpower connection is necessary only if the PMU 15 must awaken the systemfrom the OFF state by activating VP outputs on lines 33 in response totransitions on the EXT input. If this function is not required, then thePMU 15 may be powered off when the system is powered off, and the OFFstate as described below is not required.

In the OFF state, all outputs from the PMU 15 are either low ortristated, and all devices other than PMU 15 in the computer 3 arepowered off. Any inputs will have pulldowns so that floating inputs, ifany, will not cause increased power dissipation. Only activity on theEXT, RI or RTC inputs can cause an exit from OFF, and the new state willbe ON. The bus 5 interface is inhibited and data bus 5 is tristated.

Activity Monitor

The activity monitor 16 includes an address detector 73 which receivesaddresses from bus 5 representing the address activity of the CPU 4. Theaddress detector 73 receives, for example, control lines and addresslines SA(0 . . . 9) from bus 5 for sensing when those addresses arewithin the predetermined address set. The predetermined address set isdefined, for example, by an address set specified by ACTMASK register54. The detector 73 compares or masks the address set specified byregister 74 with the addresses on bus 5 and provides an address detectsignal on line 76 to the logic 77. The logic 77 receives the otherinputs to the activity monitor 16 and combines them, using conventionallogic circuitry, to provide three outputs.

The three outputs provided by activity monitor 16 are produced byconventional logic or by software as shown in TABLE 1. The EXTRIG outputis a function of keyboard activity only and is used to retrigger the ELbacklight timer 67. The LCDTRIG output is true for keyboard activity orvideo memory writes, and retriggers the LCD timer 66. The ACTIVITYoutput is an OR function of a programmable selection of differentactivities specified in the ACTMASK register 54. When active, thisoutput returns the PMU 15 to the ON state and retriggers the DOZEtimeout timer 63. The activity monitor 16 does not produce the ACTIVITYoutput in response to accesses to the registers of PMU 15.

OSC Programmability

The OSC frequency of refresh control unit 20 provides the timebase forthe timers and the refresh for DRAM memory 11. The PMU 15 may beprogrammed to accept a range of OSC frequencies. The OSC frequency ofoscillator 43 is fed to a counter 44 which divides it by a divisor whichis programmed in the OSC register 56. The programmable counter output ofdivider 44 is divided to produce 256 Hz which is used by the refreshcontrol logic 48. Further dividing in divider 46 produces 32 Hz for slowrefresh to refresh control logic 48, and 8 Hz and 1/(7.5) Hz for use bythe timers 63, 64, 65 and 68.

Timers

There are six timers in the PMU 15, namely, DOZE timer 63, SLEEP timer64, LB (low battery) timer 68, SUSPEND timer 65, EL (backlight) timer66, and LCD timer 67. Each of the six timers a 4-bit register loadableby CPU 4 over bus 5. Setting a timer register to 0 disables it; settingit to a nonzero value enables it. If enabled, certain timers aretriggered by the transition to the ON state. Individual timers are alsotriggered by events specific to their functions. Some timers areretriggerable, timing out at a programmable time following the lasttrigger.

The DOZE timer 63 is programmable from 1 to 15 seconds with a resolutionof 1 second, and the SUSPEND timer 65 is programmable from 5 to 75minutes with a resolution of 5 minutes. All other timers areprogrammable from 1 to 15 minutes with a resolution of one minute. Thereis a quantization error associated with retriggering any timer. Thiserror is a quantization error associated with retriggering any timer.This error will cause the actual timeout to be up to 1/8 of theresolution of the timer longer (but never shorter) than the programmedvalue. The error does not vary with the programmed value.

The LCD timer 66 and the EL timer 67 are retriggerable. The timeroutputs are AND'ed in AND gates 41 and 42 with the power control bitsselected by the power control multiplexer 76 according to the currentPMU state to control the LCD (VP0) and EL (VP1) power control outputs toEXOR 35. This operation provides the flexibility to turn the EL and LCDoutputs off when the associated timers 66 and 67 time out, or to controlthe outputs in any PMU power-management state under control ofmultiplexer 76.

The DOZE timer 63 is retriggerable and is triggered by the activitymonitor ACTIVITY output in the ON state, and triggers the transition toDOZE state when it times out.

The SLEEP timer 64 is triggered when the DOZE state is entered and iscleared when the DOZE state is exited. Timer 64 either generates NMI ortriggers the transition to SLEEP state when it times out.

The SUSPEND timer 65 is triggered when the SLEEP state is entered and iscleared when SLEEP is exited. If unmasked, an NMI will be generated whenit times out.

The LB timer 68 is enabled when ACPWR is false (no AC power). Timer 68is triggered when LB is first detected. If unmasked, NMI is generated bythe LB timer 68 output once per minute when it times out, until a periodof one minute elapses during which LB remains continuously false. TheNMI cause will be identified as an LB or LLB interrupt. Software canmaintain a counter and display a message once per X interrupts. It canalso monitor LLB and shut the computer down after Y interrupts. It canalso monitor LLB and shut the computer down after Y interrupts with LLBtrue.

NMI

The PMU unit 15 OR's together a number of internally generated NMIrequests to produce the NMI output on line 27. These requests can bemasked by bits in the NMIMASK register 55. The INMI input comes fromconventional external NMI-generating logic such as a parity detector,and can be OR'ed with the internal NMI requests to generate NMI whenunmasked by the OS2 bit in the NMIMASK register 55. The NMI output online 27 generally goes to the CPU NMI input, except on OS2 systems whereit must go to an IRQ. The NMI CAUSE code bits in the Status register 40indicate the cause of the NMI on line 27. An internally generated NMI iscleared by reading the NMIMASK register 55.

NMI may be generated to indicate a low battery when ACPWR is false.

If the MSKSLEEP bit is cleared, the PMU 15 will generate NMI when theSLEEP timer 64 times out and remain in DOZE instead of entering SLEEP.

NMI is also generated when the SUSPEND timer 65 times out. Software canthen save status and go to SUSPEND or OFF state.

A high on the EXT input while not in the OFF or SUSPEND state willgenerate NMI. Software can then save status and go to SUSPEND or OFFstate. If the NMI is not serviced within 5 seconds, the PMU 15 assumesthere is no software support for SUSPEND and will turn all power off andenter the OFF state.

Refresh In SUSPEND State

Refresh is enabled by setting the RASWIDTH[0 . . . 1] bits in the OSCregister 56 to a nonzero value. This enables OSC to run in SUSPEND mode,and the RASWIDTH value also sets the width of the *RAS pulse in units ofOSC clock periods. Slow refresh is enabled by setting SLWREF high. ThePMU 15 generates *MRAS and *MCAS signals to mux 32 to refresh DRAM whilethe CPU is powered off or being reset. When the CPU is active, the*PCRAS, *PCCAS signals on lines 30 from the PC controller 13 areselected by multiplexer 30 to provide the *RAS, *CAS signals on lines29. *REFRSEL on line 72 will go low to indicate that the PMU 15 iscontrolling refresh and high for PC controller 13 control.

If enabled, the DRAM refresh outputs are active in SUSPEND. Whenentering SUSPEND, the PMU 15 immediately generates a burst of 1024 CASbefore RAS refresh cycles. A burst of 256 cycles is then repeated every3.9 ms if SLOWREF is false or every 31.25 ms if SLOWREF is true. Afterentering the ON state from SUSPEND, the PMU 15 generates bursts of 1024refresh cycles over 2.9 ms. This operation allows as much time as neededfor CPU power stabilization, crystal oscillator startup and CPU reset.When the CPU is ready to take over control of the DRAM, it must poll theSUPPLY register 38 until the DRAMRDY bit goes high. The PMU 15 sensesthe polling operation as a request from the CPU for DRAM control, and atthe end of the first refresh burst following a CPU I/O read of theSUPPLY register 38, the PMU 15 sets *REFRSEL high to return control ofthe DRAM to the CPU. The DRAMRDY bit is essentially the same signal as*REFRSEL.

The purpose of the bursts when entering and leaving SUSPEND is toeliminate violations of the refresh rate spec when switching betweenexternal refresh row address generation (DMA cycles during ON) andinternal row address generation (CAS before RAS during SUSPEND).

Pseudostatic RAM refresh is also supported. When *REFRSEL goes low, *RAScan drive *RFSH low for auto refresh mode. The burst refresh will assurethat switching between external and internal refresh will not violatethe refresh rate spec. Self refresh can also be used by driving *RFSHlow when *REFRSEL is low, but other logic will have to generate therefresh burst when entering and leaving SUSPEND, if required.

External Wakeup Inputs

RI is a rising edge sensitive input, to state logic 23 from a modem ringindicator RI output of a peripheral 7. The number of rising edgesrequired for this input to be recognized is specified in bits D[4 . . .6] of the Control register 53. The default is one transition. If thesebits are zero, this input is disabled. If enabled, a rising transitionon this input will force the PMU 15 to the ON state.

RTC is an edge sensitive wakeup-alarm input from a real time clock inCPU clock control 49 of FIG. 3. A rising or falling transition on thisinput will force the PMU 15 to the ON state.

EXT is a rising edge sensitive input, intended for use with an externalpushbutton. A rising transition on this input while the PMU 15 is in OFFor SUSPEND will force the PMU 15 to the ON state. A transition in ON,DOZE or SLEEP will generate NMI.

EXT is debounced in ON, DOZE and SLEEP in a conventional debouncercircuit 36. A rising edge immediately generates NMI but only if EXT hasbeen sampled low at least twice by a 32 Hz debounce clock from counter46 prior to the rising edge. The debounce clock is derived from OSC 43and therefore may be stopped in SUSPEND and OFF, so the PMU 15 will notenter these states until the debounce operation is completed. To preventresuming due to contact bounce on the release of a pushbutton, the PMU15 will defer execution of a change of state command from the CPU 4until after the EXT input has been sampled low twice by the debouncecircuit 36. This operation is typically transparent to software. Forexample, if the user presses the button in ON, the PMU 15 will generateNMI, and the CPU will write the command to enter SUSPEND and thenexecute a halt instruction. Nothing will happen until after thepushbutton is released, at which time the PMU 15 will enter SUSPEND.

Resume and Power On

The PMU 15 has its own private *RESET signal, typically from an externalRC network detector 71 which detects VCC. This signal resets only thePMU 15 when power, VCC, is first applied to it. A separate reset signalmust be generated by external hardware for the CPU when entering the ONstate from SUSPEND or OFF state. At power on, the CPU 4 must read theRESUME bit in the Status register 51. RESUME will be cleared if thestartup is a cold start from OFF and will be set to indicate a warmstart (resume) from SUSPEND. If RESUME is cleared, the wakeup bits WU[0. . . 1] in the Status register 51 will be zero, otherwise they willindicate which external input caused the resume. The RESUME bit will becleared after the Status register is read.

Clock Switching

The clock switch control 69 is provided to switch input clocks CLK1INand CLK2IN clocks to output clocks CLK1OUT AND CLK20UT for peripherals.The CLK1 and CLK2 operations are the same. For example, the CLK1IN ispassed to the CLK1OUT output by control 69 in ON and DOZE. When enteringSLEEP mode, CLK1OUT will stop synchronously in the low state. CLK1OUTwill start synchronously when returning to the ON state.

Low Battery Detection

The LB and LLB inputs indicate low battery and low low battery asgenerated by a conventional battery level detector in power supply 9 ofFIG. 1. The polarity of these inputs is programmable by the LBPOL linewhich can be strapped low or high. If this line is high, LB and LLB arehigh true. If low, these inputs are low true. The status of the LB andLLB lines after polarity correction can be read in the SUPPLY register38. A low battery indication can generate NMI.

Power Sequencing

To minimize turnon transients, the turnon of VP1 (EL power) is delayedby 4 to 8 ms after OSC begins clocking, when entering the ON state.

Program Listing

A computer program embodiment of the hardware monitor for the powermanagement unit appears in the following TABLE 1.

                                      TABLE 1                                     __________________________________________________________________________    ;==================================================                           ; Power Management Software                                                   ;==================================================                           ;  Copyright - 1989 Vadem, Inc.                                               ;                                                                             ;  All Rights Reserved.                                                       ;                                                                             ;    C:                                                                       ;==================================================                           .xlist                                                                        include                                                                            romeq.dec                                                                include                                                                            romdef.dec                                                               include                                                                            seteq.dec                                                                include                                                                            clkeq.dec                                                                include                                                                            8250eq.dec                                                               include                                                                            prneq.dec                                                                include                                                                            crteq.dec                                                                include                                                                            vg600.dec                                                                include                                                                            notes.dec                                                                include                                                                            kbdeq.dec                                                                .list                                                                         include                                                                            pwreq.dec                                                                CMSG <Power Management BIOS Kernel>                                           pmdata segment para public `pmdata`                                           extrn                                                                              on.sub.-- power.sub.-- status:word                                       extrn                                                                              sleep.sub.-- power.sub.-- status:word                                    extrn                                                                              lb.sub.-- event.sub.-- handler:dword                                     extrn                                                                              lb.sub.-- event.sub.-- mask:word                                         extrn                                                                              doze.sub.-- timeout:byte                                                 extrn                                                                              doze.sub.-- count:byte                                                   extrn                                                                              sleep.sub.-- timeout:byte                                                extrn                                                                              sleep.sub.-- count:byte                                                  extrn                                                                              kbd.sub.-- timeout:byte                                                  extrn                                                                              kbd.sub.-- count:byte                                                    extrn                                                                              pwr.sub.-- off.sub.-- timeout:word                                       extrn                                                                              pwr.sub.-- off.sub.-- count:word                                         extrn                                                                              led.sub.-- time.sub.-- on:byte                                           extrn                                                                              led.sub.-- time.sub.-- off:byte                                          extrn                                                                              led.sub.-- next.sub.-- event:byte                                        extrn                                                                              led.sub.-- cycle.sub.-- count:word                                       extrn                                                                              lb.sub.-- def.sub.-- event.sub.-- type:byte                              extrn                                                                              lb.sub.-- event.sub.-- rep:byte                                          extrn                                                                              lb.sub.-- event.sub.-- count:byte                                        extrn                                                                              sleep.sub.-- save.sub.-- buf:byte                                        extrn                                                                              pm.sub.-- flags:byte                                                     extrn                                                                              second.sub.-- counter:byte                                               extrn                                                                              minute.sub.-- counter:byte                                               extrn                                                                              one.sub.-- shot.sub.-- handler:dword                                     extrn                                                                              one.sub.-- shot.sub.-- timer:dword                                       extrn                                                                              lb.sub.-- last.sub.-- event:word                                         extrn                                                                              pm.sub.-- ram.sub.-- chksum:word                                         extrn                                                                              pm.sub.-- save.sub.-- ss:word                                            extrn                                                                              pNi.sub.-- save.sub.-- sp:word                                           extrn                                                                              pm.sub.-- resume.sub.-- stack:byte                                       pmdata                                                                             ends                                                                     data0                                                                              segment public `DATA0`                                                   extrn                                                                              crt.sub.-- addr:word                                                     extrn                                                                              reset.sub.-- flag:word                                                   data0                                                                              ends                                                                     code segment  word public  `code`                                             assume                                                                             cs:code, ds:pmdata                                                       public                                                                             power.sub.-- management                                                  ,power.sub.-- management.sub.-- init,power.sub.-- management.sub.--           enable                                                                        public                                                                             pm.sub.-- timer.sub.-- hook,pm.sub.-- kbd.sub.-- hook                    public                                                                             pm.sub.-- enter.sub.-- sleep, read.sub.-- com, write com                 public                                                                             write.sub.-- crt.sub.-- reg, read.sub.-- crt.sub.-- reg                  public                                                                             suspend, resume                                                          extrn                                                                              data0p:word                                                              extrn                                                                              get.sub.-- pm.sub.-- ds:near                                             extrn                                                                              alloc.sub.-- pm.sub.-- ds:near                                           extrn                                                                              default.sub.-- low.sub.-- battery.sub.-- alarm:near                      extrn                                                                              rd.sub.-- rtcw:near                                                      extrn                                                                              wr.sub.-- rtcw:near                                                      extrn                                                                              rd.sub.-- rtcb:near                                                      extrn                                                                              wr.sub.-- rtcb:near                                                      extrn                                                                              play.sub.-- song:near                                                    extrn                                                                              set.sub.-- ibm.sub.-- timer:near                                         extrn                                                                              checksum:near                                                            extrn                                                                              oem.sub.-- pm.sub.-- init:near                                           extrn                                                                              oem.sub.-- pm.sub.-- get.sub.-- status:near                              extrn                                                                              oem.sub.-- pm.sub.-- extensions:near                                     extrn                                                                              oem.sub.-- pm.sub.-- halt:near                                           extrn                                                                              oem.sub.-- pm.sub.-- activity?:near                                      extrn                                                                              oem.sub.-- pm.sub.-- reset.sub.-- activity:near                          extrn                                                                              oem.sub.-- pm.sub.-- toggle.sub.-- led:near                              extrn                                                                              oem.sub.-- pm.sub.-- turn.sub.-- on.sub.-- peripherals:near              extrn                                                                              oem.sub.-- pm.sub.-- turn.sub.-- off.sub.-- peripherals:near             extrn                                                                              oem.sub.-- pm.sub.-- power.sub.-- off:near                               extrn                                                                              oem.sub.-- pm.sub.-- suspend:near                                        extrn                                                                              oem.sub.-- pm.sub.-- blank.sub.-- video:near                             extrn                                                                              oem.sub.-- pm.sub.-- restore.sub.-- video:near                           extrn                                                                              oem.sub.-- pm.sub.-- save.sub.-- peripherals:near                        extrn                                                                              oem.sub.-- pm.sub.-- restore.sub.-- peripherals:near                     extrn                                                                              oem.sub.-- pm.sub.-- save.sub.-- video.sub.-- state:near                 extrn                                                                              oem.sub.-- pm.sub.-- restore.sub.-- video.sub.-- state:near              extrn                                                                              oem.sub.-- pm.sub.-- kbd activity?:near                                  extrn                                                                              oem.sub.-- pm.sub.-- reset.sub.-- kbd.sub.-- activity:near               extrn                                                                              oem.sub.-- pm.sub.-- make.sub.-- power.sub.-- off.sub.-- noise:near      extrn                                                                              oem.sub.-- pm.sub.-- make.sub.-- low.sub.-- battery.sub.-- noise:near    extrn                                                                              oem.sub.-- pm.sub.-- defaults:near                                       extrn                                                                              oem.sub.-- pm.sub.-- get.sub.-- hw:near                                  extrn                                                                              oem.sub.-- pm.sub.-- get.sub.-- nmi.sub.-- handler:near                  es.sub.-- arg                                                                      equ word ptr [bp+16]                                                     ah.sub.-- arg                                                                      equ byte ptr [bp+15]                                                     al.sub.-- arg                                                                      equ byte ptr [bp+14]                                                     ax.sub.-- arg                                                                      equ word ptr [bp+14]                                                     cx.sub.-- arg                                                                      equ word ptr [bp+12]                                                     cl.sub.-- arg                                                                      equ byte ptr [bp+12]                                                     ch.sub.-- arg                                                                      equ byte ptr [bp+13]                                                     dx.sub.-- arg                                                                      equ word ptr [bp+10]                                                     dl.sub.-- arg                                                                      equ byte ptr [bp+10]                                                     dh.sub.-- arg                                                                      equ byte ptr [bp+11]                                                     bh.sub.-- arg                                                                      equ byte ptr [bp+09]                                                     bl.sub.-- arg                                                                      equ byte ptr [bp+08]                                                     bx.sub.-- arg                                                                      equ word ptr [bp+08]                                                     bp.sub.-- arg                                                                      equ word ptr [bp+04]                                                     si.sub.-- arg                                                                      equ word ptr [bp+02]                                                     di.sub.-- arg                                                                      equ word ptr [bp+00]                                                     page                                                                          pwrmgt.sub.-- fx.sub.-- table  label word                                     dw   pm.sub.-- get.sub.-- profile                                                                     ;get current profile                                  dw   pm.sub.-- get.sub.-- rtc.sub.-- profile                                                          ;get profile in rtc                                   dw   pm.sub.-- set.sub.-- profile                                                                     ;set active profile                                   dw   pm.sub.-- set.sub.-- rtc.sub.-- profile                                                          ;update rtc profile                                   dw   pm.sub.-- event.sub.-- handler                                                                   ;install evt handler                                  dw   pm.sub.-- one.sub.-- shot.sub.-- event.sub.-- handler                                            ;install evt handler                                  dw   pm.sub.-- get.sub.-- pm.sub.-- status                                                            ;get status                                           dw   pm.sub.-- enter.sub.-- sleep                                                                     ;enter sleep                                          dw   oem.sub.-- m.sub.-- power.sub.-- off                                                             ;power off                                            dw   oem.sub.-- m.sub.-- suspend                                                                      ;suspend                                              pwrmgt.sub.-- fx.sub.-- table.sub.-- len equ ($-pwrmgt.sub.-- fx.sub.--       table)/2                                                                      ;==================================================                           : power.sub.-- management.sub.-- init                                         ;==================================================                           ;                                                                             ; Called to initialize the Data Structures for                                ; the power management kernel. Alocate a Data Segment                         ; initialize variables, install the default                                   ; Low Battery event handler, and call oem.sub.-- pm.sub.-- defaults           ; to setup any system specific hardware or default                            ; settings. Does not enable the power management yet . . .                    power.sub.-- management.sub.-- init proc                                      dbMESSAGE fTEST8+fTESTb <power.sub.-- management.sub.-- init>                 call alloc.sub.-- pm.sub.-- ds                                                                        ;now sets ds . . .                                    sub  ax, ax                                                                   mov  pm.sub.-- flags, al                                                      mov  second.sub.-- counter, 18                                                mov  minute.sub.-- counter, 60                                                                        ;init this stuff . . .                                mov  ax,(SYS.sub.-- PWR.sub.-- MGT shl 8) or GET.sub.-- RTC.sub.--                 PWR.sub.-- PROFILE                                                       int  TASKINT                                                                  push dx                 ;save power off timeout                               mov  ax,(SYS.sub.-- PWR.sub.-- MGT shl 8) or SET.sub.-- PWR.sub.--                 PROFILE                                                                  int  TASKINT                                                                  mov  ah, CM.sub.-- ALM.sub.-- REP                                                                     ;get alarm repeat                                     call rd.sub.-- rtcb                                                           mov  cl, al             ;input param                                          mov  ah, CM.sub.-- DEF.sub.-- ALM                                             caIl rd.sub.-- rtcb                                                           mov  bl, al                                                                   and  bx, LBE.sub.-- LB1 or LBE.sub.-- LB2                                                             ;default event type . . .                             pop  dx                 ;restore pwr.sub.-- off.sub.-- timeout                mov  ax,(SYS.sub.-- PWR.sub.-- MGT shl 8) or INSTALL.sub.-- LP.sub.--              EVT.sub.-- HANDLER                                                       push cs                                                                       pop  es                                                                       mov  di, offset default.sub.-- low.sub.-- battery.sub.-- alarm                int  TASKINT                                                                  jmp  oem.sub.-- pm.sub.-- defaults                                            power.sub.-- management.sub.-- init endp                                      ;==================================================                           ; Start Power Management . . .                                                ;==================================================                           ;                                                                             ; After Initial Power Up Self Tests are completed,                            ; power management is enabled. Do not enable until                            ; it is time to boot the system.                                              ;                                                                             power.sub.-- management.sub.-- enable proc                                    push ds                                                                       call get.sub.-- pm.sub.-- ds   ;load ds pointer                               or pm.sub.-- flags, PM.sub.-- ENABLED                                         pop ds                                                                        ret                                                                           power.sub.-- management.sub.-- enable endp                                    ;==================================================                           ; Power Management dispatch routine                                           ;==================================================                           ;                                                                             ; Programmatic interface to the Power Management Kernel.                      ; used to read /alter management parameters.                                  ;                                                                             ; This function is installed as Int 15h (task management)                     ; function 0CFh.                                                              Power.sub.-- Management proc near                                             sti                                                                           cmp  al, PM.sub.-- OEM.sub.-- FX                                                                      ;extended function??                                  jnz  @F                 ;no. . .                                              jmp  oem.sub.-- pm.sub.-- extensions                                                                  ;do private functions                                 @@:  cmp al,pwrmgt.sub.-- fx.sub.-- table.sub.-- len                          jae  md.sub.-- err      ;not here                                             push ds                                                                       push es                                                                       pusha                                                                         mov  bp,sp              ;stack addressing . . .                               call get.sub.-- pm.sub.-- ds                                                                          ;load ds pointer                                      sub  ah,ah                                                                    sh1  ax,1                                                                     mov  si,ax                                                                    call pwrmgt.sub.-- fx.sub.-- table[si]                                                                ;execute the.sub.-- function                          popa                                                                          pop  es                                                                       pop  ds                                                                       retf 2                  ;return                                               md.sub.-- err:                                                                     mov ah,86h         ;fx err                                               stc                                                                           retf 2                  ;save flags                                           Power.sub.-- Management endp                                                  page                                                                          ;==================================================                           ; pm.sub.-- get.sub.-- profile                                                ;==================================================                           ;                                                                             ; Return to caller the current active profile.                                ; This may have been modified by Set profile calls.                           ;                                                                             pm.sub.-- get.sub.-- profile:                                                 dbMESSAGE fTEST8+fTESTb <pm.sub.-- set.sub.-- profile>                        mov  ax,on.sub.-- power.sub.-- status                                         mov  si.sub.-- arg, ax                                                        mov  ax, sleep.sub.-- power.sub.-- status                                     mov  di.sub.-- arg, ax                                                        mov  al,lb.sub.-- def.sub.-- event.sub.-- type                                mov  bl.sub.-- arg, al                                                        rriov                                                                              al,kbd.sub.-- timeout                                                    mov  bh.sub.-- arg, al                                                        mov  al,doze.sub.-- timeout                                                   mov  cl.sub.-- arg, al                                                        mov  al, sleep.sub.-- timeout                                                 mov  ch.sub.-- arg, al                                                        mov  ax,pwr.sub.-- off.sub.-- timeout                                         mov  dx.sub.-- arg, ax                                                        clc                                                                           ret                                                                           ;==================================================                           ; pm.sub.-- set.sub.-- profile                                                ;==================================================                           ;                                                                             ; Setthe current active profile.                                              ; Alter the desired parameters. Do this by calling                            ; get profile, and then changing just those parameters                        ; and then calling set profile                                                pm.sub.-- set.sub.-- profile:                                                 dbMESSAGE fTEST8+fTESTb <pm.sub.-- set.sub.-- profile>                        mov  doze.sub.-- timeout, cl                                                  mov  sleep.sub.-- timeout, ch                                                 mov  lb.sub.-- def.sub.-- event.sub.-- type, bl                               mov  kbd.sub.-- timeout, bh                                                   mov  pwr off.sub.-- timeout, dx                                               mov  pwr.sub.-- off.sub.-- count,0                                                                    ;clear countdown                                      mov  ax, si.sub.-- arg                                                        mov  on.sub.-- power.sub.-- status, ax                                        mov  ax, di.sub.-- arg                                                        mov  sleep.sub.-- power.sub.-- status, ax                                     mov  ax, si.sub.-- arg                                                        call oem.sub.-- pm.sub.-- turn.sub.-- on.sub.-- peripherals                   clc                                                                           ret                                                                           page                                                                          ;==================================================                           ; pm.sub.-- get.sub.-- profile                                                ;==================================================                           ;                                                                             ; Return to caller the current active profile.                                ; This may have been modified by Set profile calls.                           ;                                                                             pm.sub.-- get.sub.-- profile:                                                 dbMESSAGE fTEST8+fTESTb <pm.sub.-- get.sub.-- profile>                        mov  ax,on.sub.-- power.sub.-- status                                         mov  si.sub.-- arg, ax                                                        mov  ax,sleep.sub.-- power.sub.-- status                                      mov  di.sub.-- arg, ax                                                        mov  al,lb.sub.-- def.sub.-- event.sub.-- type                                mov  bl.sub.-- arg, al                                                        mov  al,kbd.sub.-- timeout                                                    mov  bh.sub.-- arg, al                                                        mov  al,doze.sub.-- timeout                                                   mov  cl.sub.-- arg, al                                                        mov  al,sleep.sub.-- timeout                                                  mov  ch.sub.-- arg, al                                                        mov  ax,pwr.sub.-- off.sub.-- timeout                                         mov  dx.sub.-- arg, ax                                                        clc                                                                           ret                                                                           ;==================================================                           ; pm.sub.-- set.sub.-- profile                                                ;==================================================                           ;                                                                             ; Set the current active profile.                                             ; Alter the desired parameters. Do this by calling                            ; get profile, and then changing just those parameters                        ; and then calling set profile                                                pm.sub.-- set.sub.-- profile:                                                 dbMESSAGE fTEST8+fTESTb <pm.sub.-- set.sub.-- profile>                        mov  doze.sub.-- timeout, cl                                                  mov  sleep.sub.-- timeout, ch                                                 mov  lb.sub.-- def.sub.-- event.sub.-- type, bl                               mov  kbd.sub.-- timeout, bh                                                   mov  pwr.sub.-- off.sub.-- timeout, dx                                        mov  pwr.sub.-- off.sub.-- count,0                                                                    ;clear countdown                                      mov  ax, si.sub.-- arg                                                        mov  on.sub.-- power.sub.-- status, ax                                        mov  ax, di.sub.-- arg                                                        mov  sleep.sub.-- power.sub.-- status, ax                                     mov  ax, si.sub.-- arg                                                        call oem.sub.-- pm.sub.-- turn.sub.-- on.sub.-- peripherals                   clc                                                                           ret                                                                           page                                                                          ;==================================================                           ; pm.sub.-- get.sub.-- rtc.sub.-- profile                                     ;==================================================                           ; Read Back current prbfile stored in the NV-RAM.                             ; This profile is the default active at power up                              ;                                                                             pm.sub.-- get.sub.-- rtc.sub.-- profile                                       dbMESSAGE fTEST8+fTESTb <pm.sub.-- get.sub.-- rtc.sub.-- profile>             mov  ah,CM.sub.-- OPCW                                                        call rd.sub.-- rtcw                                                           inov si.sub.-- arg, bx                                                        mov  ah,CM.sub.-- SPCW                                                        call rd.sub.-- rtcw                                                           mov  di.sub.-- arg, bx                                                        mov  ah,CM.sub.-- DOZE                                                        call rd.sub.-- rtcw                                                           mov  cx.sub.-- arg, bx                                                        mov  ah,CM.sub.-- ALM.sub.-- REP                                              call rd.sub.-- rtcw                                                           mov  dx.sub.-- arg, bx                                                        mov  ah,CM.sub.-- DEF.sub.-- ALM                                              call rd.sub.-- rtcw                                                           mov  bx.sub.-- arg, bx                                                        clc                                                                           ret                                                                           ;==================================================                           ; pm.sub.-- set.sub.-- rtc.sub.-- profile                                     ;==================================================                           ;                                                                             ; Set the current NV-RAM profile.                                             ; Alter the desired parameters. Do this by calling                            ; get rtc profile, and then changing just those parameters                    ; and then calling set rtc profile                                            ; This profile will be active next hard reset . . .                           pm.sub.-- set.sub.-- rtc.sub.-- profile:                                      dbMESSAGE fTEST8+fTESTb <pm.sub.-- set.sub.-- rtc.sub.-- profile>             mov  ah, CM.sub.-- OPCW                                                       mov  bx, si.sub.-- arg                                                        call wr.sub.-- rtcw                                                           mov  ah, CM.sub.-- SPCW                                                       mov  bx, di.sub.-- arg                                                        call wr.sub.-- rtcw                                                           mov  ah,CM.sub.-- DOZE                                                        mov  bx, cx.sub.-- arg                                                        call wr.sub.-- rtcw                                                           mov  ah,CM.sub.-- ALM.sub.-- REP                                              mov  bx, dx.sub.-- arg                                                        call wr.sub.-- rtcw                                                           mov  ah,CM.sub.-- DEF.sub.-- ALM                                              mov  bx, bx.sub.-- arg                                                        call wr.sub.-- rtcw                                                           clc                                                                           ret                                                                           page                                                                          ;==================================================                           ; pm.sub.-- event.sub.-- handler                                              ;==================================================                           ;                                                                             ; Install a Low.sub.-- Battery Event Handler.                                 ; Specify the Event criteria, which dictates                                  ; under which conditions the Event Handler is called,                         ; and specify a repeat rate for recurring conditions.                         ; Also specify a power off/ Suspend timeout                                   ; after the detection of a Low, Low Battery condition                         pm.sub.-- event.sub.-- handler:                                               dbMESSAGE fTEST8+fTESTb <pm.sub.-- event.sub.-- handler>                      xchg [lb.sub.-- event.sub.-- mask],bx                                         mov bx.sub.-- arg, bx                                                         xchg word ptr [lb.sub.-- event.sub.-- handler],di                             mov  di.sub.-- arg, di                                                        mov  bx,es.sub.-- arg                                                         xchg word ptr [lb.sub.-- event.sub.-- handler+2],bx                           mov  es.sub.-- arg, bx                                                        xchg [lb.sub.-- event.sub.-- rep], cl                                         mov  cl.sub.-- arg, cl                                                        xchg [pwr.sub.-- off.sub.-- timeout], dx                                      mov  dx.sub.-- arg, dx                                                        and  [pm.sub.-- flags],not PM.sub.-- LB.sub.-- HANDLER                        mov  ax, word ptr [lb.sub.-- event.sub.-- handler]                            or   ax, word ptr [lb.sub.-- event.sub.-- handler+2]                          jz   @F                                                                       or   [pm.sub.-- flags],PM.sub.-- LB.sub.-- HANDLER                            @@:  mov [lb.sub.-- event.sub.-- count], 0                                                            ;time to do . . .                                     clc                                                                           ret                                                                           ;==================================================                           ; pm.sub.-- one.sub.-- shot.sub.-- event.sub.-- handler                       ;==================================================                           ;                                                                             ; Certain applications and/or management functions                            ; may wish to be notified if a timebut period occurs                          ; after a certain event. This function provides                               ; a 55 Msec resolution timing function for timing                             ; events, and acts like a hardware one-shot; timing out                       ; calling the one shot handler, and cancelling the                            ; timer until it is reloaded again.                                           pm.sub.-- one.sub.-- shot.sub.-- event.sub.-- handler:                        dbMESSAGE fTEST8+fTESTb <pm.sub.-- one.sub.-- shot.sub.-- handler>            mov  word ptr [one.sub.-- shot.sub.-- handler],di                             mov  bx,es.sub.-- arg                                                         mov  word ptr [one.sub.-- shot.sub.-- handler+2],bx                           mov  word ptr [one.sub.-- shot.sub.-- timer], cx                              mov  word ptr [one.sub.-- shot.sub.-- timer+2], dx                            mov  al, [pm.sub.-- flags]                                                                            ;get status                                           or   cx, dx             ;cancel??                                             jz   os.sub.-- cancel   ;yes . . .                                            ;====  Not a Cancel request1 so check if one shot is rolling                  test al, PM.sub.-- ONE.sub.-- SHOT.sub.-- HANDLER                             jnz  os.sub.-- err                                                            and  al, not PM.sub.-- ONE.sub.-- SHOT.sub.-- HANDLER                         mov  bx, word ptr [one.sub.-- shot.sub.-- handler]                            or   bx, word ptr [one.sub.-- shot.sub.-- handler+2]                          jz   @F                                                                       or   al, PM.sub.-- ONE.sub.-- SHOT.sub.-- HANDLER                             @@   mov [pm.sub.-- flags], al                                                clc                                                                           ret                                                                           os.sub.-- err: mov ah.sub.-- arg,86h                                                                  ;already active                                       stc                                                                           ret                                                                           os.sub.-- cancel:                                                             and  al, not PM.sub.-- ONE.sub.-- SHOT.sub.-- HANDLER                         mov  [pm.sub.-- flags], al                                                    clc                                                                           ret                                                                           ;==================================================                           ; pm.sub.-- get.sub.-- m.sub.-- status                                        ;==================================================                           ;                                                                             ; Return the status of the System Status port.                                ; this port has two defined bits:                                             ;                                                                             ; bit 0 = Low Battery                                                         ; bit 1 = Low, Low Battery                                                    ;                                                                             ; bit 0 = Low Battery                                                         ; bit 1 = Low, Low Battery                                                    ;                                                                             ; Other bits have OEM specific meanings                                       pm.sub.-- get.sub.-- m.sub.-- status:                                         dbMESSAGE fTEST8+fTEST.b <pm.sub.-- get.sub.-- pm.sub.-- status>              call oem.sub.-- pm.sub.-- get.sub.-- status                                   mov bx arg, ax                                                                ret                                                                           ;==================================================                           ; pm.sub.-- enter.sub.-- sleep                                                ;==================================================                           ;                                                                             ; This function sets up a sleep command at the                                ; next timer interrupt.                                                       pm.sub.-- enter.sub.-- sleep:                                                 or pm.sub.-- flags, PM.sub.-- SLEEP                                                                   ;say to sleep                                         ret                                                                           assume cs:code,ds:data0,es:pmdata                                             ;==================================================                           ; read.sub.-- crt.sub.-- reg                                                  ;==================================================                           ;                                                                             ; This routine is used to read the state of a                                 ; video register                                                              ;                                                                             ;                                                                             ; inputs:  bl           = address in 6845                                     ;                                                                             ; outputs:  ax          = word read                                           ;==================================================                           read.sub.-- crt.sub.-- reg proc near                                          mov  dx,crt.sub.-- addr ;set addr                                             mov  al,bl                                                                    out  dx,al                                                                    inc  dl                                                                       in   al,dx                                                                    mov  ch,al              ;get msb                                              dec  dl                                                                       mov  al,bl              ;set next addr                                        inc  al                                                                       out  dx,al                                                                    inc  dl                                                                       in   al,dx                                                                    mov  ah,ch              ;get lsb                                              ret                                                                           read.sub.-- crt.sub.-- reg endp                                               ;==================================================                           ; read.sub.-- com                                                             ;==================================================                           ;                                                                             ; This routine is used to read the status of a                                ; 8250 serial port and save it in memory                                      read.sub.-- com  proc       ;save com port in DX                              add  dl,lcr                                                                   in   al,dx                                                                    or   al,DLAB            ;set dlab to read div reg                             jmp  $+2                                                                      out  dx,al                                                                    sub  dl,lcr                                                                   in   ax,dx              ;read divisor reg                                     stosw                                                                         add  dl,lcr                                                                   in   al,dx                                                                    and  al,not DLAB                                                              jmp  $+2                                                                      out  dx,al                                                                    sub  dl,lcr-ier                                                               mov  cx,6                                                                     rcom1:                                                                             in  al,dx                                                                inc  dx                                                                       stosb                                                                         loop rcom1                                                                    ret                                                                           read.sub.-- com                                                                       endp                                                                  ;==================================================                           ; read.sub.-- lpt                                                             ;==================================================                           ;                                                                             ; This routine is used to read the status of a                                ; Industry Standard Parallel port and save it in memory                       read.sub.-- lpt  proc                                                         add dl,printer.sub.-- control                                                 in al,dx                                                                      stosb                                                                         ret                                                                           read.sub.-- lpt  endp                                                         assume cs:code,ds:pmdata,es:data0                                             ;==================================================                           ; write.sub.-- com                                                            ;==================================================                           ;                                                                             ; This routine is used to restore the status of a                             ; 8250 serial port from where it was saved in memory                          write.sub.-- com proc                                                         add  dl,lcr                                                                   in   al,dx                                                                    or   al,DLAB                                                                  jmp  $+2                                                                      out  dx,al                                                                    sub  dl,lcr                                                                   lodsw                                                                         out  dx,ax                                                                    add  dl,lcr                                                                   in   al,dx                                                                    and  al,not DLAB                                                              jmp  $+2                                                                      out  dx,al                                                                    sub  dl,lcr-ier                                                               mov  cx,6                                                                     wcom1:                                                                             lodsb                                                                    out  dx,al                                                                    inc  dx                                                                       loop wcom1                                                                    ret                                                                           write.sub.-- com  endp                                                        ;==================================================                           ; write.sub.-- 1pt                                                            ;==================================================                           ;                                                                             ; This routine is used to restore the status of a                             ; Industry Standard Parallel port from                                        ; where it was saved in memory                                                write.sub.-- 1pt  proc                                                        add dl,printer.sub.-- control                                                 lodsb                                                                         out dx,al                                                                     ret                                                                           write.sub.-- 1pt  endp                                                        ;==================================================                           ; write crt register                                                          ;                                                                             ; This routine is used to restore the status of a                             ; video register from memory                                                  ;                                                                             ; inputs:  cx   = word to write                                               ;   bl   = address in 6845                                                    ;==================================================                           write.sub.-- crt.sub.-- reg proc near                                         mov  dx,crt.sub.-- addr ;set addr                                             mov  al,bl                                                                    out  dx,al                                                                    mov  al,ch              ;send msb                                             inc  dl                                                                       out  dx,al                                                                    dec  dl                                                                       mov  al,bl              ;set next addr                                        inc  al                                                                       out  dx,al                                                                    inc  dl                                                                       mov  al,cl              ;send lsb                                             out  dx,al                                                                    ret                                                                           write.sub.-- crt.sub.-- reg endp                                              assume cs:code,ds:pmdata,es:nothing                                           page                                                                          ;==================================================                           ; pm.sub.-- kbd.sub.-- hook                                                   ;==================================================                           ;                                                                             ; In Software Based Power Management, this routine                            ; is part of the Keyboard Interrupt chain. It is                              ; used to detect keyboard activity.                                           ;                                                                             ; Called every KBD INT: Set Keyboard Active bit                               ;                                                                             ; restore video if necessary                                                  ;                                                                             ; must save regs, take care of ints . . .                                     ;                                                                             ;                                                                             pm.sub.-- kbd.sub.-- hook:                                                    dbPC fTEST1+fTESTb "k"                                                        call get.sub.-- pm.sub.-- ds                                                                          ;get ds                                               test pm.sub.-- flags, PM.sub.-- VBLANK                                                                ;video blanked out???                                 jz @F                   ;NO                                                   call oem.sub.-- pm.sub.-- restore.sub.-- video                                                        ;turn on screen                                       and pm.sub.-- flags, not PM.sub.-- VBLANK                                                             ;clear blank flag                                     @@:   or  pm.sub.-- flags, PM.sub.-- KBDACT                                                               ;say keyboard had                                 activity                                                                      ret                                                                           page                                                                          ;==================================================                           ; pm.sub.-- Timer.sub.-- hook                                                 ;==================================================                           ;                                                                             ; In Software Based Power Management, this routine                            ; performs the function of the Timer and Dispatcher                           ; It is part of the Timer Interrupt chain1 after                              ; the timer end of interrupt (EOI) has been sent.                             ;                                                                             ; Checks for system activity and DOZES/ SLEEPs                                ;                                                                             ; Entry conditions:  cli, ds,es,pusha saved, ds=data0p                        ; This routine contains two threads of code,                                  ; which execute independently.                                                ;                                                                             ;                                                                             ; COUNTER thread:                                                             ; .sub.------------                                                           ;                                                                             ;                                                                             ; The COUNTER thread checks for the one shot,                                 ; handles the second and minute counters, and looks                           ; at the iow battery level, and dispatches the LB                             ; event handler. It then looks at the DOZE flag,                              ; and if doze is active, returns without changing                             ; the activity status; so that the code after the DOZE                        ; HLT can function.                                                           ;                                                                             ;                                                                             ; DOZE thread:                                                                ; .sub.------------                                                           ;                                                                             ;                                                                             ; The DOZE thread runs when an activity check                                 ; shows no activity has been present for the                                  ; entire DOZE timeout. The processor clock                                    ; is slowed, the DOZE bit is set1 interrupts                                  ; are enabled, and the CPU is put into HLT.                                   ; When HLT is exited1 (18.2 hz) the activity                                  ; status is checked, to see if DOZE should be                                 ; terminated. If activity is present,                                         ; the DOZE flag is cleared and the                                            ; activity exit is taken.                                                     ; If activity is not present, a test is made                                  ; for the SLEEP timeout. If the SLEEP timeout                                 ; has elapsed, SLEEP is entered, after saving                                 ; the peripheral state. Otherwise, the CPU                                    ; is halted, and the DOZE loop is reentered,                                  ; and the cycle continues until                                               ; terminated by ACTIVITY or SLEEP.                                            ;                                                                             ;==================================================                           even                    ;fast . . .                                           pm.sub.-- timer.sub.-- hook:                                                  cli                     ;ints are off . . .                                   call get.sub.-- pm.sub.-- ds                                                                          ;establish ds                                         test pm.sub.-- flags, PM.sub.-- ENABLED                                                               ;running yet??                                        jnz  @F                                                                       jmp  exit.sub.-- wo.sub.-- change                                                                     ;no . . .                                             @@:  call oem.sub.-- pm.sub.-- get.sub.-- hw                                                              ;get hw.sub.-- caps to                            ES:DI                                                                         test pm.sub.-- flags, PM.sub.-- ONE.sub.-- SHOT.sub.-- HANDLER                                        ;have one??                                           jz   ck.sub.-- sec      ;no . . .                                             dec  word ptr one.sub.-- shot.sub.-- timer                                    sbb  word ptr one.sub.-- shot.sub.-- timer,0                                  jnz  ck.sub.-- sec                                                            and  pm.sub.-- flags, not PM.sub.-- ONE.sub.-- SHOT.sub.-- HANDLER ;dont           any more . . .                                                           call one.sub.-- shot.sub.-- handler                                                                 ;called w/ ints disabled                                ;==================================================                           ; First, handle the one second dispatching                                    ;==================================================                           even                                                                          ck.sub.-- sec:                                                                dec  second.sub.-- counter                                                    jz   is.sub.-- sec                                                            jmp  exit.sub.-- wo.sub.-- change                                             ;==================================================                           ; Second Rolled, Check Minutes                                                ;==================================================                           is.sub.-- sec: mov second.sub.-- counter,18                                                           ;ticks per second . . . reset                         dbPC fTEST2+fTESTb " Q"                                                       dec  minute.sub.-- counter                                                                            ;count minutes . . .                                  jz   @f                                                                       jmp  not.sub.-- minute                                                        @@:  dbpC fTEST2+fTESTb "("                                                   page                                                                          ;==================================================                           ; All Code Below is executed once per Minute.                                 ; All Minute Counters are decremented here . . .                              ;==================================================                           mov  minute.sub.-- counter, 60                                                                        ;reset                                                ;==================================================                           ; Count Down Sleep Timer                                                      ;==================================================                           ; Turned On by Entering Doze . . .                                            sub  ax, ax             ;for resetting                                        cmp  sleep.sub.-- timeout,al                                                                          ;timeout used??                                       jz   lb.sub.-- dec      ;NO                                                   mov  al, sleep.sub.-- count                                                                           ;get sleep counter                                    test al,al                                                                    jz   @F                                                                       dec  al                 ;dec sleep counter                                    @@:  mov sleep.sub.-- count, al                                                                           ;reset                                            ;==================================================                           ; Count Down low battery event Timer                                          ;==================================================                           ;                                                                             ; Rep count set by LB event detection                                         lb.sub.-- dec:                                                                cmp  lb.sub.-- event.sub.-- rep,ah                                                                    ;timeout used??                                       jz   kbd.sub.-- dec     ;NO                                                   mov  al, lb.sub.-- event.sub.-- count                                                                 ;dec event counter                                    test al, al             ;already 0???                                         jz   @F                 ;yes . . .                                            dec  al                 ;dec rep counter                                      @@:  mov lb.sub.-- event.sub.-- count, al                                                                 ;reset                                            ;==================================================                           ; Check For Keyboard Activity                                                 ;==================================================                           even                                                                          kbd.sub.-- dec:                                                               test es:[dij].HW.sub.-- CAPS, HWC.sub.-- KBACT                                jz   pwr.sub.-- dec   ;doesnt support KB activity                             call oem.sub.-- pm.sub.-- kbd.sub.-- activity?                                                        ;kbd active??                                         jnz  nokbact            ;yes, normal                                          dbPC fTEST2+fTESTb " Y"                                                       ;==================================================                           ; Count Down Keyboard Timer                                                   ;==================================================                           ;                                                                             ; Turned On by No Kbd Activity . . .                                          cmp  kbd.sub.-- timeout,0                                                                             ;timeout used??                                       jz   pwr.sub.-- dec     ;NO                                                   mov  all kbd.sub.-- count                                                                             ;get blank counter                                    test al,al              ;done . . .                                           jz   pwr.sub.-- dec                                                           dec  al                 ;dec sleep counter                                    mov  kbd.sub.-- count, al                                                                             ;reset to 0                                           jnz  pwr.sub.-- dec     ;next counter                                         or   pm.sub.-- flags, PM.sub.-- VBLANK                                                                ;say its off . . .                                    call oem.sub.-- pm.sub.-- blank.sub.-- video                                                          ;blank the video                                      jmp  short pwr.sub.-- dec                                                     nokbact:                                                                      mov  al,kbd.sub.-- timeout                                                                            reset counter                                         mov  kbd.sub.-- count, al                                                     call oem.sub.-- pm.sub.-- reset.sub.-- kbd.sub.-- activity                                            ;clear activity bit                                   ;==================================================                           ; Count Down Power Off Timer                                                  ;==================================================                           ;                                                                             ; Turned On by LB2 detection below, and powers off                            ; if hw supports it                                                           ;                                                                             even                                                                          pwr.sub.-- dec:                                                               test es:[di].HW.sub.-- CAPS, HWC.sub.-- POWER                                 jz   not.sub.-- po      ;doesnt support power off                             cmp  pwr.sub.-- off.sub.-- timeout,0                                                                  ;Countdown enabled??                                  jz   not.sub.-- po      ;NO                                                   dec  pwr.sub.-- off.sub.-- count                                                                      ;dec event counter                                    jnz  not.sub.-- po                                                            dbPC fTEST2+fTESTb "p"                                                        call oem.sub.-- pm.sub.-- power.sub.-- off                                    not.sub.-- po:                                                                dbPC fTEST2+fTESTb `)`                                                        page                                                                          ;==================================================                           ; All Code Below is execute once a Second                                     ;==================================================                           even                                                                          not.sub.-- minute:                                                            ;==================================================                           ; Check and attend to the low battery indicators . . .                        ;==================================================                           ;                                                                             ; Once a Second, we check the Battery Levels via                              ; polling. Since some hardware generates an NMI,                              ; we inay not need to do this, Since the NMI will                             ; be invoked at event time.                                                   ;                                                                             ; The Event Handler is assumed not to be re-entrant,                          ; so it will not be re-entered until the first event                          ; is handled. The next event will trigger as soon as                          ; the PM.sub.-- IN.sub.-- LB.sub.-- HANDLER flag is cleared.                  ;                                                                             ; Handler or no, the power off/Suspend Timeout is started                     ; at Low, Low Battery detection.                                              test es:[di].HW.sub.-- CAPS, HWC LB.sub.-- NMI                                jnz  ck.sub.-- led    ;supports nmi, dont need this                           call oem.sub.-- pm.sub.-- get.sub.-- status                                                           ;get this stuff                                       and  ax, lb.sub.-- event.sub.-- mask                                                                  ;need to attend to??                                  jz   ck.sub.-- lb       ;no . . .                                             test pm.sub.-- flags, PM.sub.-- LB.sub.-- HANDLER                                                     ;have one??                                           jnz  ck.sub.-- ilbh     ;yes . . .                                            ck.sub.-- lb:                                                                      mov lb.sub.-- event.sub.-- count, 0                                                              ;clear rep count for re-                              entry . . .                                                                   ck.sub.-- lba:                                                                     test ax, LBE.sub.-- LB2                                                                          ;need to start power                                  off??                                                                         jz   ck.sub.-- led      ;no . . .                                             jmp  short pwr.sub.-- ct                                                                              ;still count power off                                ck.sub.-- ilbh:                                                               dbPC fTEST2+fTESTb "v"                                                        test pm.sub.-- flags, PM.sub.-- IN.sub.-- LB.sub.-- HANDLER                                           ;Blocked??                                            jnz  ck.sub.-- lb2      ;dont reenter                                         cmp  ax, lb.sub.-- last.sub.-- event                                                                ;same event as previously??                             jnz  ck.sub.-- fevt                                                           cmp  lb.sub.-- event.sub.-- count,0                                                                   ;time to repeat??                                     jnz  ck.sub.-- lb2      ;no . . .                                             even                                                                          ck.sub.-- fevt:                                                               mov  lb.sub.-- last.sub.-- event,ax                                                                   ;save event                                           or   pm.sub.-- flags, PM.sub.-- IN.sub.-- LB.sub.-- HANDLER                   mov  bl,lb.sub.-- def.sub.-- event.sub.-- type                                                        ;default criteria                                     push ax                                                                       call lb.sub.-- event.sub.-- handler                                                                   ;do it, LB flags in                                   ax . . .                                                                      pop  ax                                                                       mov  bl, lb.sub.-- event.sub.-- rep                                                                   ;reset                                                mov  lb.sub.-- event.sub.-- count, bl                                                                 ;event rep time                                       and  pm.sub.-- flags, not PM.sub.-- IN.sub.-- LB.sub.-- HANDLER               ;==================================================                           ; Start power off timeout/suspend machine                                     ;==================================================                           ck.sub.-- lb2:                                                                     test ax, LBE.sub.-- LB2                                                                          ;need to start power                                  off??                                                                         jz   ck.sub.-- led      ;no . . .                                             cmp  pwr.sub.-- off.sub.-- count,0                                                                    ;started previously??                                 jnz  ck.sub.-- led      ;yes . . .                                            pwr.sub.-- ct:                                                                     mov ax, pwr.sub.-- off timeout                                                                   ;start event                                          test ax,ax              ;immediate off/suspend???                             jnz  pwr.sub.-- to      ;no . . .                                             test es:[di].HW.sub.-- CAPS, HWC.sub.-- SUSPEND                               jz   ck.sub.-- led      ;doesnt support suspend                               dbPC fTEST2+fTESTb "o"                                                        call suspend            ;suspend the machine . . .                            jmp  exit.sub.-- w.sub.-- activity                                                                    ;yes, run now . . .                                   pwr.sub.-- to:                                                                     mov pwr.sub.-- off.sub.-- count, ax                                                              ;counter                                              ;==================================================                           ; Handle LED Flash Cycles                                                     ;==================================================                           ;                                                                             ; Some OEMs flash LEDs at different duty cycles to                            ; indicate different operational conditions.                                  ;                                                                             ; On/Off modulation is provided by this function.                             ;                                                                             ; LED flash cycles are handled                                                ; during the once per second loop                                             ;                                                                             even                                                                          ck.sub.-- led:                                                                test es:[di].HW.sub.-- CAPS, HWC.sub.-- LEDS                                  jz   ck.sub.-- activity ;doesnt support LEDs                                  cmp  led.sub.-- time.sub.-- on, 0                                                                     ;LED cycle active??                                   jz   ck.sub.-- activity ;no                                                   dec  led.sub.-- next.sub.-- event                                                                     ;dec counter to next                                  delta                                                                         jnz  ck.sub.-- activity ;Non-zero, wait                                       ;==== LED event time, toggle state, inc counters                              call oem.sub.-- pm.sub.-- toggle.sub.-- led                                   mov  al, led.sub.-- time.sub.-- off                                                                   ;NO                                                   jz   ck.sub.-- led2                                                           mov  ax, led.sub.-- cycle.sub.-- count                                                                ;count infinite . . .                                 test ax, ax             ;yes . . .                                            jz   ck.sub.-- led1                                                           dec  ax                                                                       mov  led.sub.-- cycle.sub.-- count, ax                                                                ;dec count every ON . . .                             jnz  ck.sub.-- led1     ;not timed out yet . . .                              mov  led.sub.-- time.sub.-- on, 0                                                                     ;LED cycle NOT active                                 ck.sub.-- led1:                                                               mov  al, led.sub.-- time.sub.-- on                                            ck.sub.-- led2:                                                               mov  led.sub.-- next.sub.-- event, al                                                                 ;reset                                                ;==================================================                           ; Next, check if reentering from DOZE timer int                               ;==================================================                           ;                                                                             ; Thread detection logic:                                                     ; we made it to here1 so lets see if we need to                               ; exit to block again in DOZE, or to process a sleep                          ; command, or perhaps enter doze.                                             ;                                                                             ; If the DOZE flag is set, this means we entered the                          ; timer hook from doze. we should then exit without                           ; resetting the activity monitor, and let the DOZE thread                     ; see if something happened to run Full Clock speed.                          ;                                                                             ;                                                                             ; If the DOZE flag is not set, check and see if No activity                   ; has been present for the DOZE timeout, and enter DOZE if so.                ; Otherwise reset the activity monitor.                                       even                                                                          ck.sub.-- activity:                                                           test pm.sub.-- flags, PM.sub.-- SLEEP                                                                 ;Req to sleep??                                       jz   @F                                                                       call sleep              ;yes . . .                                            call oem.sub.-- pm.sub.-- halt                                                jmp  wake               ;run . . .                                            @@:  test pm.sub.-- flags, PM.sub.-- DOZE                                                                 ;Were WE dozing . . .                             jz   @F                 ;no                                                   jmp  exit.sub.-- wo.sub.-- change                                                                     ;YES, exit to code below                              ;==== Next, check the activity Monitor =====                                  @@:  dbPC fTEST2+fTESTb "I"                                                   call oem.sub.-- pm.sub.-- activity?                                                                   ;turns ints off . . .                                 jnz  exit.sub.-- w.sub.-- activity                                                                    ;yes, normal                                          cmp  doze.sub.-- timeout, 0                                                                           ;doze allowed??                                       jz   @F                 ;NO                                                   dec  doze.sub.-- count  ;timeout??                                            jnz  @F                                                                       jmp  go.sub.-- doze                                                           @@:  sti                                                                      jmp  exit.sub.-- wo.sub.-- change                                             ;==================================================                           ; exits . . .                                                                 ;==================================================                           ; Various exits to the COUNTER and DOZE threads . . .                         ;                                                                             ; Depending on Activity conditions                                            even                                                                          exit.sub.-- w.sub.-- activity:                                                ;===Exit, and reset the activity monitor                                      sti                                                                           mov  al, doze.sub.-- timeout                                                  mov  doze.sub.-- count, al                                                    ;=== Exit, and reset the activity monitor                                     exit.sub.-- w.sub.-- clear:                                                   dbPC fTEST2+fTESTb " p"                                                       call oem.sub.-- pm.sub.-- reset.sub.-- activity                               exit.sub.-- wo.sub.-- change:                                                 ret                                                                           page                                                                          ;==================================================                           ; go.sub.-- doze                                                              ;==================================================                           ;                                                                             ; At this point, we enter DOZE, having fulfilled the                          ; criteria to enter that STATE                                                ;                                                                             even                                                                          go.sub.-- doze:                                                               mov  al, sleep.sub.-- timeout                                                                         ;start sleep counter                                  mov  sleep.sub.-- count, al                                                                           ;each time doze re-                                   entered                                                                       or   pm.sub.-- flags, PM.sub.-- DOZE                                                                  ;in doze                                              dbPC fTEST2+fTESTb "d"                                                        slow.sub.-- cpu:                                                              call oem.sub.-- pm.sub.-- halt                                                                        ;slow cpu, do halt                                    ;==== When we start up here, the sleep.sub.-- check will already              have                                                                          ; been run and taken the early return                                         call oem.sub.-- pm.sub.-- activity?                                           jz   ck.sub.-- sleep    ;no, chk sleep                                        and  pm.sub.-- flags, not PM.sub.-- DOZE                                                              ;clear doze flag                                      jmp  exit.sub.-- w.sub.-- activity                                                                    ;yes, normal                                          ;==================================================                           ; Decrement Sleep Counters . . .                                              ;==================================================                           ;                                                                             ; At this point, we enter check .the SLEEP counters                           ; for criteria to enter that STATE. If not, reenter                           the DOZE loop                                                                 ;                                                                             ck.sub.-- sleep:                                                              sub  al,al              ;register zero                                        cmp  sleep.sub.-- timeout,al                                                                          ;sleep allowed.                                       jz   slow.sub.-- cpu    ;NO                                                   cmp  sleep.sub.-- count,al                                                                            ;sleep time??                                         jnz  slow.sub.-- cpu    ; no                                                  call sleep              ;enter sleep mode                                     and  pm.sub.-- flags, not PM.sub.-- DOZE                                                              ;clear doze flag                                      jmp  exit.sub.-- w.sub.-- activity                                                                    ;because we came out . . .                            page                                                                          ;==================================================                           ; Sleep                                                                       ;==================================================                           ;                                                                             ; At this point, we enter SLEEP, having fulfilled the                         ; criteria to enter that STATE                                                ;                                                                             ; Save, in order:                                                             ; Video Adaptor state                                                         ; LCD state                                                                   ; 8250 modes                                                                  ; LPT modes                                                                   ; Timer Mask                                                                  ;==================================================                           Sleep:                                                                        dbPC  fTEST2+fTESTb "S"                                                       push  di                                                                      push  si                                                                      push  cx                                                                      mov   di,offset sleep.sub.-- save.sub.-- buf                                  cld                                                                           and   pm.sub.-- flags, not PM.sub.-- SLEEP                                                            ;starting sleep req                                   assume                                                                              cs:code,ds:data0,es:pmdata                                              push  ds                                                                      pop   es                                                                      mov   ds,data0p                                                               ;==================================================                           ; save Display State                                                          ;==================================================                           call oem.sub.-- pm.sub.-- save.sub.-- video.sub.-- state                      ;==================================================                           ; save COM, LPT setups                                                        ;==================================================                           mov  dx, COM1           ;get COM1                                                  call read.sub.-- com                                                     mov  dx, COM2           ;get COM2                                             call read.sub.-- com                                                          mov  dx, LPT1           ;get LPT1                                             call read.sub.-- 1pt                                                          mov  dx, LPT2                                                                 call read.sub.-- 1pt                                                          mov  dx, LPT3                                                                 call read.sub.-- 1pt                                                          call oem.sub.-- pm.sub.-- save.sub.-- periphera1s                                                     ;for private stuff . . .                              sleep.sub.-- cpu                                                              in   al, PIC1           ;get timer mask                                       stosb                                                                              ;save                                                                    or   al, TMRINT                                                               out  PIC1,al          ;disable the timer interrupt                            assume                                                                             cs:code,ds:pmdata,es:data0                                               push es                                                                       pop  ds                                                                       mov  es,data0p          ;swap ES/DS                                           mov  ax,sleep.sub.-- power.sub.-- status                                                              ;turns off stuff . . .                                call oem.sub.-- pm.sub.-- turn.sub.-- off.sub.-- peripherals ;actually             turns off                                                                stuff. . .                                                                    ret                                                                           page                                                                          wake:                                                                         ;=====  Restore Peripheral Status==================                           ;                                                                             ; Because we are here, this means the wakeup key                              ; was pressed, or an external interrupt came in.                              ; Time to wake up . . .                                                       ;                                                                             ;                                                                             ; Restore, in order:                                                          ; Video Adaptor state                                                         ; 8250 mode                                                                   ; LPT mode                                                                    ; Timer interrupt                                                             ;==================================================                           cli                                                                           mov  ax,on.sub.-- power.sub.-- status                                                                 ;What to turn on . . .                                call oem.sub.-- pm.sub.-- turn.sub.-- on.sub.-- peripherals                                           ;go do it                                             mov  si,offset sleep.sub.-- save.sub.-- buf                                                           ;start of save area                                   cld                                                                           ;==================================================                           ; Restore Display State                                                       ;==================================================                           call oem.sub.-- pm.sub.-- restore.sub.-- video.sub.-- state                   ;==================================================                           ; restore COM and PRN                                                         ;==================================================                           mov  dx,COM1            ;get com port                                         call write.sub.-- com                                                         mov  dx,COM2            ;get com port                                         call write.sub.-- com                                                         mov  dx,LPT1            ;restore lpt port                                     call write.sub.-- lpt                                                         mov  dx,LPT2            ;restore lpt port                                     call write.sub.-- lpt                                                         mov  dx,LPT3            ;restore lpt port                                     call write.sub.-- 1pt                                                         call oem.sub.-- pm.sub.-- restore.sub.-- peripherals                                                  ;for private stuff . . .                              push ds                                                                       call set.sub.-- ibm.sub.-- timer                                                                      ;restore ticks . . .                                  pop  ds                                                                       lodsb                                                                         out  PIC1,al            ; reenable interrupts                                 pop  cx                                                                       pop  si                                                                       pop  di                                                                       dbPC fTEST2+fTESTb "G"                                                        ret                                                                           page                                                                          ;==================================================                           ; suspend                                                                     ;==================================================                           ;                                                                             ; Swap stacks, to                                                             ;                                                                             ;                                                                             assume                                                                            cs:code,es:data0,ds:pmdata                                                suspend                                                                           proc                                                                                 ;====== Save User Stack =====                                      cli                                                                           mov  ax,ss                                                                    mov  pm.sub.-- save.sub.-- ss, ax ;save stack                                 mov  ax,sp                                                                    mov  pm.sub.-- save.sub.-- sp, ax                                             sti                                                                           ;====== Run On Resume Stack=====                                              mov  ax, ds                                                                   mov  ss, ax             ;setup resume stack                                   mov  sp, offset pm.sub.-- resume stack                                        mov  es,data0p                                                                mov  reset.sub.-- flag, FRESTORE                                              call checksum           ;check this memory                                    mov  pm.sub.-- ram.sub.-- chksum, ax                                                                  ;save in pm.sub.-- datat                              call sleep              ;save it all . . .                                    call oem.sub.-- pm.sub.-- suspend                                                                     ;do . . .                                             ;==================================================                           ; pm.sub.-- resume                                                            ;==================================================                           ;                                                                             ; Cold Boot code jmps here with BP as no resume                               ; return address . . .                                                        ;                                                                             ; check for a valid resume, do so                                             ;                                                                             ; otherwise, jmp bp to cold boot code                                         resume:                                                                       mov  es,data0p                                                                cmp  reset.sub.-- flag, FRESTORE                                              jnz  resume.sub.-- err                                                        ;===== PM data should still be valid =====                                    call get.sub.-- pm.sub.-- ds ;get datasg                                      mov  ax, ds                                                                   mov  ss, ax             ;setup resume stack                                   mov  sp, offset pm.sub.-- resume.sub.-- stack                                 call checksum                                                                 cmp  ax, pm.sub.-- ram.sub.-- chksum                                          jnz  resume.sub.-- err                                                        call wake               ;restore devices . . .                                ;===== Restore User Stack =========                                           mov  ax, pm.sub.-- save.sub.-- ss                                             mov  Ss, ax                                                                   mov  sp, pm.sub.-- save.sub.-- sp                                             ret                     ;to suspend caller                                    resume.sub.-- err:                                                            jmp  bp                 ;return to do a hard                                  reset                                                                         suspend                                                                            endp                                                                     code ends                                                                     end                                                                           __________________________________________________________________________

                  TABLE 2                                                         ______________________________________                                        Program Listing                                                               A computer program embodiment of the software monitor for                     the power management unit appears in the following TABLE 2.                   ;===================================================== ;                      Do power management functions of int 16h and int 8h                           ;     Copyright - 1990 Vadem, Inc.                                            ;                                                                             ;     All Rights Reserved.                                                    ;                                                                             ;         C:                                                                  ===================================================== ;                       code    segment public  'code'                                                assume    cs:code                                                             org     100h                                                                  start:                                                                        jmp     init                                                                  even                                                                          pp.sub.-- addr                                                                        dw    0378h                                                           old.sub.-- i8                                                                         label   dword                                                         i8.sub.-- off                                                                         dw    0                                                               i8.sub.-- seg                                                                         dw    0ffffh                                                          old.sub.-- i10 label                                                                      dword                                                             i10.sub.-- off                                                                        dw    0     ; vector to old i10                                       i10.sub.-- seg                                                                        dw    0ffffh                                                          old.sub.-- i16                                                                        label   dword                                                         i16.sub.-- off                                                                        dw    0     ; vector to old i16                                       i16.sub.-- seg                                                                        dw    0ffffh                                                          sctr    db    0     ; counter for timeouts                                    two.sub.-- ctr                                                                        dw    12*182  ; 2 minute counter                                      ; - - - - Interrupt 10h handler                                               new.sub.-- i10:                                                               call    busy.sub.-- check                                                     jmp     old.sub.-- i10                                                        ; - - - - Interrupt 8 handler                                                 new.sub.-- i8:                                                                call    busy.sub.-- check                                                     jmp     old.sub.-- i8                                                         busy.sub.-- check:                                                            cmp     sctr,0    ; already in faxt mode?                                     jz      i8fast.sub.-- mode                                                    sub     sctr,50                                                               jz      i8fast.sub.-- mode                                                    jnc     i8z                                                                   mov     sctr,0                                                                ; - - - - Switch to turbo mode here!                                          i8fast.sub.-- mode:                                                           cmp     two.sub.-- ctr,0                                                                          ; if timed out, do nothing                                jz      i8z         ; let IO monitor take over                                - - - - Two minutes have not gone by, turn it to ON!                          dec     two.sub.-- ctr                                                        push    dx                                                                    push    ax                                                                    mov     dx,0178h                                                              mov     al,0c0h                                                               out     dx,al                                                                 inc     dx                                                                    in      al,dx       ; get status of chip                                      mov     ah,al                                                                 and     al,3      ; LSB 2 bits                                                jz      i8q       ; if not ON, nothing to do!                                 dec     dx                                                                    mov     al,0c0h                                                               out     dx,al                                                                 inc     dx                                                                    mov     al,ah                                                                 and     al,not 3  ; set to ON mode                                            out     dx,al                                                                 i8q:                                                                          pop     ax                                                                    pop     dx                                                                    i8z:                                                                          ret                                                                           ; - - - - Interrupt 16 interceptor                                            new.sub.-- i16:                                                               - - - - - Time to switch from ON to DOSE mode?                                push    ax                                                                    push    dx                                                                    mov     dx,0178h                                                              mov     al,0c0h                                                               out     dx,al                                                                 inc     dx                                                                    in      al,dx       ; get status of chip                                      mov     ah,al                                                                 and     al,3      ; LSB 2bits                                                 jnz     i16.sub.-- dose                                                                         ; if not ON, nothing to do!                                 ; - - - - Check to see if time to go into DOSE . . .                          add     sctr,24                                                               jnc     i16q                                                                  ; - - - - Time to go into DOZE!                                               dec     dx                                                                    mov     al,0c0h                                                               out     dx,al                                                                 inc     dx                                                                    mov     al,ah                                                                 or      al,1      ; set to dose mode                                          out     dx,al       ; we are now in DOSE mode!                                jmp     short i16setctrs                                                      ; - - - We are already in DOSE mode, count faster!                            i16.sub.-- dose:                                                              add     sctr,200                                                              jnc     i16q                                                                  i16setctrs:                                                                   mov     sctr,0ffh   ; clamp it                                                mov     two.sub.-- ctr,12 * 182                                                                     ; 18.2 Hz * 120 seconds                                 i16q:                                                                         pop     dx                                                                    pop     ax                                                                    jmp     old.sub.-- i16                                                                            ; do the original i16                                     init.sub.-- str                                                                         db    'Power management controller version 1.00.$'                  assume    ds:code                                                             init:                                                                         mov     dx,offset init.sub.-- str                                             mov     ah, 9                                                                 int     21h                                                                   mov     ax,3508h                                                              int     21h                                                                   mov     i8.sub.-- seg,es                                                      mov     i8.sub.-- off,bx                                                      push    ds                                                                    pop     es                                                                    mov     dx,offset new.sub.-- i8                                               mov     ax,2508h                                                              int     21h                                                                   mov     ax,3510h                                                              int     21h                                                                   mov     i10.sub.-- seg,es                                                     mov     i10.sub.-- off,bx                                                     push    ds                                                                    pop     es                                                                    mov     dx,offset new.sub.-- i10                                              mov     ax,2510h                                                              int     21h                                                                   mov     ax,3516h                                                              int     21h                                                                   mov     i16.sub.-- seg,es                                                     mov     i16.sub.-- off,bx                                                     push    ds                                                                    pop     es                                                                    mov     dx,offset new.sub.-- i16                                              mov     ax,2516h                                                              int     21h                                                                   mov     dx,offset init.sub.-- str+15                                          mov     cl,4                                                                  shr     dx,cl                                                                 mov     ax,3100h                                                              int     21h                                                                   code    ends                                                                  end     start                                                                 ______________________________________                                    

While the invention has been particularly shown and described withreference to preferred embodiments thereof, it will be understood bythose skilled in the art that the foregoing and other changes in formand details may-be made therein without departing from the spirit andscope of the invention.

What is claimed is:
 1. In a computer system comprising as hardware aplurality of system resources including a central processing unit (CPU),a memory device, and an input/output device, and as software, anoperating system for managing and controlling said system resources,said system being operable in any one of at least three operating modesincluding a first-mode having a first power consumption level, asecond-mode having a second power consumption level less than said firstpower consumption level, and a third-mode having a third powerconsumption level less than said second power consumption level; amethod for controlling the operating mode of said computer systemcomprising:while operating in said first mode, monitoring said computerto detect execution of a predefined code thread, and generating afirst-mode to second-mode transition command signal in response to saiddetecting execution of a predefined code thread; and changing saidoperating mode from said first-mode to said second-mode in response tosaid first-mode to second-mode transition command signal; and whileoperating in said second mode, monitoring said computer to detectoccurrence or non-occurrence of a second predefined event, andgenerating a second-mode to third-mode transition command signal inresponse to said second event detection; and changing said operatingmode from said second-mode to said third-mode in response to saidsecond-mode to third-mode transition command signal; said firstoperating mode characterized by maintaining clocking of said CPU at afirst frequency; said second operating mode characterized by clockingsaid CPU at a second frequency less than said first frequency or by notmaintaining clocking of said CPU; and said third operating modecharacterized by maintaining operation only of said memory to preservethe integrity of data stored therein.
 2. The method in claim 1, whereinsaid predefined code thread comprises an idle thread.
 3. The method inclaim 2, wherein said second predefined event comprises occurrence of atimer timeout condition a predetermined period of time after initiationof execution of said first idle thread.
 4. The method in claim 2,wherein said second predefined event comprises occurrence of apredetermined timer timeout condition.
 5. The method in claim 4, whereinsaid step of turning off at least one device comprises turning off clockto all devices except said memory.
 6. The method in claim 1, whereinsaid execution of a predefined code thread comprises execution of apredefined code segment.
 7. The method in claim 6, wherein saidpredefined code segment comprises an operating system call.
 8. Themethod in claim 7, wherein said operating system call is an interrupt.9. The method in claim 8, wherein said operating system is selected fromthe group consisting of a multi-tasking operating system, MicrosoftWindows, Microsoft DOS, and combinations thereof.
 10. The method inclaim 8, wherein said interrupt comprises an idle state interrupt. 11.The method in claim 10, wherein said idle state interrupt is selectedfrom the group consisting of DOS Idle Handler (Interrupt 28h), and DOSIdle Call (Interrupt 2Fh Function 1680).
 12. The method in claim 8,wherein said interrupt comprises an idle handler.
 13. The method inclaim 12, wherein said idle handler enables background operations whilethe system waits for input.
 14. The method in claim 12, wherein saididle handler is a operating system idle handler.
 15. The method in claim14, wherein said operating system idle handler comprises DOS Interrupt28h.
 16. The method in claim 14, wherein said operating system idlehandler comprises DOS Multiplex Interrupt (Interrupt 2Fh).
 17. Themethod in claim 14, wherein said operating system idle handler comprisesDOS Idle Call (Interrupt 2Fh Function 1680).
 18. The method in claim 12,wherein said idle handler comprises execution of an idle thread, andwherein execution of said idle thread communicates to other processes insaid computer that the computer system is idle.
 19. The method in claim8, wherein said operating system call is an operating system multiplexinterrupt and is used to monitor inter-process communications toidentify idle class calls.
 20. The method in claim 8, wherein saidoperating system call is an operating system multiplex interrupt and isused to monitor inter-process communications to identify operatingsystem start-up and shut-down.
 21. The method in claim 7, wherein saidoperating system call informs the system that the operating system isidle.
 22. The method in claim 7, wherein said CPU is executing aplurality of threads and wherein each of said threads is in an idlestate.
 23. The method in claim 22, wherein said threads have an idleclass priority such that they do not execute unless there are no threadshaving higher execution priority than said idle class priority.
 24. Themethod in claim 22, wherein a keystroke check loop has an idle priorityand is an indication of system idle.
 25. The method in claim 22, whereinherein said thread is any thread that gives an indication that thesystem is at idle.
 26. The method in claim 25, wherein said CPUgenerated command is selected from the group consisting of a system haltcommand, a system suspend command, and a system hibernate command. 27.The method in claim 25, wherein said CPU generated command is generatedwhenever an idle thread has been executing for more than a predeterminedperiod of time.
 28. The method in claim 1, wherein said first-mode tosecond-mode transition command slows or stops clocking of the CPU; andwherein said second-mode to third-mode transition command signal slowsor stops clocking of other of said system devices and resources with theproviso that inputs required for maintenance of data stored in saidmemory are maintained.
 29. The method in claim 1, wherein said secondpredetermined event comprises the occurrence of a second timer timeout.30. The method in claim 1, further comprising the steps of:whileoperating in said third mode, monitoring said computer to detectoccurrence or non-occurrence of a third predefined event, and generatinga third-mode to first-mode transition command signal in response to saidthird event detection; and changing said operating mode from saidthird-mode to said first-mode in response to said third-mode tofirst-mode transition command signal.
 31. The method in claim 30,wherein said third event is selected from the group consisting ofoccurrence of a keyboard input, modem ring indicator, real time clockalarm, external pushbutton, and any predetermined interrupt.
 32. Themethod in claim 30, wherein said second predefined event is an eventselected from the set consisting of a timeout event, a CPU commandevent, and a statistical evaluation event; and wherein said third eventis selected from the group consisting of occurrence of a keyboard input,modem ring indicator, real time clock alarm, external pushbutton, andany predetermined interrupt.
 33. The method in claim 30, furthercomprising the steps of:while operating in said second mode, monitoringsaid computer to detect occurrence or non-occurrence of a fourthpredefined event, and generating a second-mode to first-mode transitioncommand signal in response to said fourth event detection; and changingsaid operating mode from said second-mode to said first-mode in responseto said second-mode to first-mode transition command signal.
 34. Themethod in claim 33, wherein said fourth event is selected from the groupconsisting of a direct memory access (DMA), occurrence of a keyboardinput, modem ring indicator, real time clock alarm, external pushbutton,any CPU initiated activity, any predetermined interrupt, and theoccurrence of a predetermined address on a system bus.
 35. The method inclaim 30, wherein said second predefined event is an event selected fromthe set consisting of a timeout event, a CPU command event, and astatistical evaluation event; and wherein said third event is selectedfrom the group consisting of an occurrence of a keyboard input, modemring indicator, real time clock alarm, external pushbutton, and anypredetermined interrupt; and wherein said fourth event is selected fromthe group consisting of a direct memory access (DMA), occurrence of akeyboard input, modem ring indicator, real time clock alarm, externalpushbutton, any CPU initiated activity, any predetermined interrupt, andthe occurrence of a predetermined address on a system bus.
 36. Themethod in claim 1, wherein said second predefined event is an eventselected from the set consisting of a timeout event, a CPU commandevent, and a statistical evaluation event.
 37. The method in claim 1,further comprising the step of directly commanding said system to any ofsaid first-mode, second-mode, or third mode by a CPU command.
 38. In acomputer system comprising as hardware a plurality of system resourcesincluding a central processing unit (CPU), a memory device, and aninput/output device, and as software, an operating system for managingand controlling said system resources, said system being operable in anyone of at least three operating modes including a first-mode having afirst power consumption level, a second-mode having a second powerconsumption level less than said first power consumption level, and athird-mode having a third power consumption level less than said secondpower consumption level; a method for controlling the operating mode ofsaid computer system comprising:while operating in said first mode,monitoring said computer to detect exceeding a threshold value for astatistical evaluation of active and idle process, and generating afirst-mode to second-mode transition command signal in response to saiddetecting exceeding a threshold value for a statistical evaluation ofactive and idle process; and changing said operating mode from saidfirst-mode to said second-mode in response to said first-mode tosecond-mode transition command signal; and while operating in saidsecond mode, monitoring said computer to detect occurrence ornon-occurrence of a second predefined event, and generating asecond-mode to third-mode transition command signal in response to saidsecond event detection; and changing said operating mode from saidsecond-mode to said third-mode in response to said second-mode tothird-mode transition command signal; said first operating modecharacterized by maintaining clocking of said CPU at a first frequency;said second operating mode characterized by clocking said CPU at asecond frequency less than said first frequency or by not maintainingclocking of said CPU; and said third operating mode characterized bymaintaining operation only of said memory to preserve the integrity ofdata stored therein.
 39. The method as in claim 38, wherein said idleprocess makes at least one function call.
 40. The method as in claim 38,wherein said idle process is comprised of threads.
 41. The method inclaim 38, wherein said statistical evaluation comprises statisticalevaluation of active and idle function calls.
 42. In a computer systemcomprising as hardware a plurality of system resources including acentral processing unit (CPU), a memory device, and an input/outputdevice, and as software, an operating system for managing andcontrolling the system resources, at least one of said system devicesand resources being operable in any one of three operating modesincluding a first-mode having a first power consumption level, asecond-mode having a second power consumption level less than said firstpower consumption level, and a third-mode having a third powerconsumption level less than said second power consumption level; amethod for controlling the operating mode of the computer systemcomprising the steps of:while operating in said first mode, monitoringsaid computer to detect completion of execution of all idle threadsexecuting on said system, and generating a slow or stop processor clockcommand in response to said idle thread completion detection; whileoperating in said second mode wherein said CPU clock is slowed orstopped, receiving an interrupt from a timer circuit indicatingoccurrence of a predetermined timer time-out condition, and generating aslow or stop device command to slow or turn off clock signal to at leastone of said devices in response to occurrence of said timeout condition;said first operating mode characterized by maintaining clocking of saidCPU at a first clock frequency; said second operating mode characterizedby clocking said CPU at a second clock frequency less than said firstfrequency or by not maintaining clocking of said CPU; and said thirdoperating mode characterized by maintaining operation of said memory topreserve the integrity of memory contents stored therein.
 43. The methodin claim 42, further comprising the steps of:while operating in saidthird mode, monitoring said computer to detect occurrence ornon-occurrence of a third predefined event, and generating a third-modeto first-mode transition command signal in response to said third eventdetection; and changing said operating mode from said third-mode to saidfirst-mode in response to said third-mode to first-mode transitioncommand signal.
 44. The method in claim 43, wherein said third event isselected from the group consisting of occurrence of a keyboard input,modem ring indicator, real time clock alarm, external pushbutton, and apredetermined hardware interrupt.
 45. The method in claim 43, furthercomprising the steps of:while operating in said second mode, monitoringsaid computer to detect occurrence or non-occurrence of a fourthpredefined event, and generating a second-mode to first-mode transitioncommand signal in response to said fourth event detection; and changingsaid operating mode from said second-mode to said first-mode in responseto said second-mode to first-mode transition command signal.
 46. Themethod in claim 45, wherein said fourth event is selected from the groupconsisting of a direct memory access (DMA), occurrence of a keyboardinput, modem ring indicator, real time clock alarm, external pushbutton,any CPU initiated activity, any predetermined interrupt, and theoccurrence of a predetermined address on a system bus.
 47. The method inclaim 42, wherein said first predefined event is an event selected fromthe set consisting of a timeout event, a CPU command event, and astatistical evaluation event; and wherein said second predefined eventis an event selected from the set consisting of a timeout event, a CPUcommand event, and a statistical evaluation event; and wherein saidthird event is selected from the group consisting of an occurrence of akeyboard input, modem ring indicator, real time clock alarm, externalpushbutton, and any predetermined interrupt; and wherein said fourthevent is selected from the group consisting of a direct memory access(DMA), occurrence of a keyboard input, modem ring indicator, real timeclock alarm, external pushbutton, any CPU initiated activity, anypredetermined interrupt, and the occurrence of a predetermined addresson a system bus.
 48. A computer system including as hardware a pluralityof system resources including a processing unit responsive to aprocessor clock signal, a memory device, and an input/output device, andan operating system for controlling operation of said computer system,at least one of said system devices and resources being operable in anyone of at least three operating modes including a first-mode having afirst power consumption level, a second-mode having a second powerconsumption level less than said first power consumption level, and athird-mode having a third power consumption level less than said secondpower consumption level; said computer system characterized in that saidcomputer system further comprises:idle thread execution completiondetection means for monitoring said computer system to detect completionof execution of all idle threads executing on said system whileoperating in said first mode; processor clock speed control means forslowing or stopping said processor clock signal in response to said idlethread execution completion detection; a timer circuit generating atimer-timeout signal indicating occurrence of a predetermined timertime-out condition; a device controller receiving said timer-timeoutsignal while operating in said second mode wherein said processor clockis slowed or stopped and generating a slow or stop device signal to slowor turn off clock signal to at least one of said devices in response tooccurrence of said timer timeout condition; said first operating modecharacterized by maintaining clocking of said processor at a first clockfrequency; said second operating mode characterized by clocking saidprocessor at a second clock frequency less than said first frequency orby not maintaining clocking of said processor; and said third operatingmode characterized by maintaining operation of said memory to preservethe integrity of memory contents stored therein.